public class ExcelReader extends Object implements AutoCloseable
Sheet.reset() method.
The internal Row object of the same Sheet page is memory shared,
so don't directly convert Stream<Row> to a collection class.
You should first consider using try-with-resource to use Reader
or manually close the ExcelReader.
try (ExcelReader reader = ExcelReader.read(path)) {
reader.sheets().flatMap(Sheet::rows).forEach(System.out::println);
} catch (IOException e) {}| 限定符和类型 | 字段和说明 |
|---|---|
static int |
COPY_ON_MERGED
Copy value on merge cells
|
protected Path |
self |
protected Sheet[] |
sheets |
static int |
VALUE_AND_CALC
Parse cell value and calc
|
static int |
VALUE_ONLY
Specify
ExcelReader only parse cell value (Default) |
| 限定符 | 构造器和说明 |
|---|---|
protected |
ExcelReader() |
| 限定符和类型 | 方法和说明 |
|---|---|
Sheet[] |
all()
get all sheets
|
void |
close()
close stream and delete temp files
|
ExcelReader |
copyOnMergeCells()
Copy values when reading merged cells.
|
AppInfo |
getAppInfo()
General information like title,subject and creator
|
protected AppInfo |
getGeneralInfo(Path tmp) |
int |
getSize()
size of sheets
|
ExcelType |
getType()
Type of excel
|
boolean |
hasFormula()
Check current workbook has formula
|
ExcelReader |
parseFormula()
Make the reader parse formula
|
static ExcelReader |
read(InputStream stream)
Constructor Excel Reader
|
static ExcelReader |
read(InputStream stream,
int option)
Constructor Excel Reader
|
static ExcelReader |
read(InputStream stream,
int bufferSize,
int option)
Constructor Excel Reader
|
static ExcelReader |
read(InputStream stream,
int bufferSize,
int cacheSize,
int option)
Constructor Excel Reader
|
static ExcelReader |
read(Path path)
Constructor Excel Reader
|
static ExcelReader |
read(Path path,
int option)
Constructor Excel Reader
|
static ExcelReader |
read(Path path,
int bufferSize,
int option)
Constructor Excel Reader
|
static ExcelReader |
read(Path path,
int bufferSize,
int cacheSize,
int option)
Constructor Excel Reader
|
Sheet |
sheet(int index)
get by index
|
Sheet |
sheet(String sheetName)
get by name
|
Stream<Sheet> |
sheets()
to streams
|
public static final int VALUE_ONLY
ExcelReader only parse cell value (Default)public static final int VALUE_AND_CALC
public static final int COPY_ON_MERGED
protected Path self
protected Sheet[] sheets
public static ExcelReader read(Path path) throws IOException
path - the excel pathExcelReaderIOException - if path not exists or I/O error occurpublic static ExcelReader read(InputStream stream) throws IOException
stream - the InputStream of excelExcelReaderIOException - if I/O error occurpublic static ExcelReader read(Path path, int option) throws IOException
path - the excel pathoption - the reader option.ExcelReaderIOException - if path not exists or I/O error occurpublic static ExcelReader read(InputStream stream, int option) throws IOException
stream - the InputStream of exceloption - the reader option.ExcelReaderIOException - if I/O error occurpublic static ExcelReader read(Path path, int bufferSize, int option) throws IOException
path - the excel pathbufferSize - the SharedStrings buffer size. default is 512
This parameter affects the number of read times.option - the reader option.ExcelReaderIOException - if path not exists or I/O error occurpublic static ExcelReader read(InputStream stream, int bufferSize, int option) throws IOException
stream - the InputStream of excelbufferSize - the SharedStrings buffer size. default is 512
This parameter affects the number of read times.option - the reader option.ExcelReaderIOException - if I/O error occurpublic static ExcelReader read(Path path, int bufferSize, int cacheSize, int option) throws IOException
path - the excel pathbufferSize - the SharedStrings buffer size. default is 512
This parameter affects the number of read times.cacheSize - the Cache size, default is 512option - the reader option.ExcelReaderIOException - if path not exists or I/O error occurpublic static ExcelReader read(InputStream stream, int bufferSize, int cacheSize, int option) throws IOException
stream - the InputStream of excelbufferSize - the SharedStrings buffer size. default is 512
This parameter affects the number of read times.cacheSize - the Cache size, default is 512option - the reader option.ExcelReaderIOException - if I/O error occurpublic ExcelType getType()
public Sheet sheet(int index)
index - sheet index of workbookpublic Sheet[] all()
public int getSize()
public void close()
throws IOException
close 在接口中 AutoCloseableIOException - when fail close readerspublic AppInfo getAppInfo()
public boolean hasFormula()
public ExcelReader parseFormula()
ExcelReaderpublic ExcelReader copyOnMergeCells()
By default, the values of the merged cells are only stored in the first Cell, and other cells have no values. Call this method to copy the value to other cells in the merge.
|---------| |---------| |---------|
| | | 1 | | | 1 | 1 |
| 1 | => |----|----| => |----|----|
| | | | | | 1 | 1 |
|---------| |---------| |---------|
Merged(A1:B2) Default Copy
Value in A1
others are
`null`
ExcelReaderCopyright © 2020. All rights reserved.