Package net.sf.basedb.util.excel
Class XlsxToCsvUtil.SheetInfo
java.lang.Object
net.sf.basedb.util.excel.XlsxToCsvUtil.SheetInfo
- Enclosing class:
- XlsxToCsvUtil
Represents a single sheet in a workbook. Use it to get access to a CSV Input stream
that is generated from the table data. It can also be used to get access to the
actual underlying Cell element for reading data directly.
-
Field Summary
Modifier and TypeFieldDescriptionprivate byte[]
private final org.apache.poi.ss.usermodel.DataFormatter
private final int
private final int
private final org.apache.poi.ss.usermodel.FormulaEvaluator
private final int
private final int
private final org.apache.poi.ss.usermodel.Sheet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate XlsxToCsvUtil.CellTypeWithInfo
evaluateFormula
(org.apache.poi.ss.usermodel.Cell cell) org.apache.poi.ss.usermodel.Cell
getCell
(int row, int col) Get the cell at the specified row and column.getCellValueAsDate
(org.apache.poi.ss.usermodel.Cell cell, Formatter<Date> parser, boolean nullIfException) Get the cell value as a date.getCellValueAsNumber
(org.apache.poi.ss.usermodel.Cell cell, NumberFormat parser, boolean nullIfException) Get the cell value as a number.getCellValueAsString
(org.apache.poi.ss.usermodel.Cell cell) Get the the cell value as a string.int
Get the column number for the first column that contains data.int
Get the row number for the first row that contains data.int
Get the column number for the last column that contains data.int
Get the row number for the last row that contains data.getName()
Get the name of the sheet.int
getSize()
Get the size of the CSV in bytes.private void
Convert the sheet to a CSV and get an InputStream for reading the data.
-
Field Details
-
sheet
private final org.apache.poi.ss.usermodel.Sheet sheet -
dataFormat
private final org.apache.poi.ss.usermodel.DataFormatter dataFormat -
formulaEval
private final org.apache.poi.ss.usermodel.FormulaEvaluator formulaEval -
firstRow
private final int firstRow -
lastRow
private final int lastRow -
firstColumn
private final int firstColumn -
lastColumn
private final int lastColumn -
csvBytes
private byte[] csvBytes
-
-
Constructor Details
-
SheetInfo
SheetInfo(org.apache.poi.ss.usermodel.Sheet sheet)
-
-
Method Details
-
getName
Get the name of the sheet. -
getFirstRow
public int getFirstRow()Get the row number for the first row that contains data. -
getLastRow
public int getLastRow()Get the row number for the last row that contains data. -
getFirstColumn
public int getFirstColumn()Get the column number for the first column that contains data. -
getLastColumn
public int getLastColumn()Get the column number for the last column that contains data. -
getCell
public org.apache.poi.ss.usermodel.Cell getCell(int row, int col) Get the cell at the specified row and column.- Returns:
- A Cell instance or null
-
getCellValueAsString
Get the the cell value as a string. Numeric cells are are checked if the seem to have a date-like format syntax (with or without time). If so, the value is formatted with the date or timestamp formatter, otherwise with the number formatter. If the required formatter has not been set, the value is formatted with the built-in formatter from Excel. -
getCellValueAsNumber
public Double getCellValueAsNumber(org.apache.poi.ss.usermodel.Cell cell, NumberFormat parser, boolean nullIfException) Get the cell value as a number. If the cell is a numeric cell, the value is returned directly, otherwise the given parser is used to parse the string data from cell, viaType.parseString(String, NumberFormat, boolean)
-
getCellValueAsDate
public Date getCellValueAsDate(org.apache.poi.ss.usermodel.Cell cell, Formatter<Date> parser, boolean nullIfException) Get the cell value as a date. If the cell is a numeric cell, the value is returned directly as if it was a date (the style format string is NOT checked), otherwise the given parser is used to parse the string data from cell, viaType.parseString(String, Formatter, boolean)
-
evaluateFormula
-
parseToCsv
Convert the sheet to a CSV and get an InputStream for reading the data. Note that the CSV will only contain data for the range of cells between firstRow, lastRow, firstColumn and lastColumn. -
getSize
public int getSize()Get the size of the CSV in bytes.- Since:
- 3.17.1
-
parseToBytes
private void parseToBytes()
-