java.lang.Object
jp.ecuacion.util.poi.excel.util.ExcelReadUtil
Provides excel reading related
apache POI utility methods.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance withNoDataString = NULL.ExcelReadUtil(NoDataString noDataString) Constructs a new instance with designatedNoDataString. -
Method Summary
Modifier and TypeMethodDescriptiongetNoDataStringIfNoData(String value) Returns properNoDataStringvalue if the argument value isnullor"", otherwize returns the argument value.getReadyToReadTableData(ExcelTableReader<T> reader, org.apache.poi.ss.usermodel.Workbook workbook, String sheetName, Integer numberOfHeaderLinesIfReadsHeaderOnlyOrNull, boolean ignoresColumnSizeSetInReader) Gets ready to read table data.getStringFromCell(org.apache.poi.ss.usermodel.Cell cell) ReturnsStringformat cell value in spite of the format or value kind of the cell.getStringFromCell(org.apache.poi.ss.usermodel.Cell cell, DateTimeFormatter dateTimeFormat) ReturnsStringformat cell value in spite of the format or value kind of the cell.org.apache.poi.ss.usermodel.WorkbookopenForRead(String filePath) Opens the excel file and returnsWorkbookobject.<T> List<T> readTableLine(ExcelTableReader<T> reader, ExcelTable.ContextContainer context, int rowNumber) Provides common procedure for read one line of a table.voidsetDefaultDateTimeFormat(DateTimeFormatter dateTimeFormat) Sets defaultDateTimeFormat.suppressesWarnLog(boolean suppressesWarnLog) SetssuppressesWarnLog.
-
Constructor Details
-
ExcelReadUtil
public ExcelReadUtil()Constructs a new instance withNoDataString = NULL.NoDataString = NULLis recommended. SeeNoDataString. -
ExcelReadUtil
Constructs a new instance with designatedNoDataString.NoDataString = NULLis recommended. SeeNoDataString.- Parameters:
noDataString- noDataString
-
-
Method Details
-
setDefaultDateTimeFormat
Sets defaultDateTimeFormat.- Parameters:
dateTimeFormat- dateTimeFormat
-
getNoDataStringIfNoData
Returns properNoDataStringvalue if the argument value isnullor"", otherwize returns the argument value.- Parameters:
value- value, may benull.- Returns:
- the argument value or the empty string designated by
noDataStringwhen the argument value is empty.
-
getStringFromCell
@Nullable public String getStringFromCell(@Nullable org.apache.poi.ss.usermodel.Cell cell) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException ReturnsStringformat cell value in spite of the format or value kind of the cell.- Parameters:
cell- the cell of the excel file- Returns:
- the string which expresses the value of the cell.
- Throws:
jp.ecuacion.lib.core.exception.checked.BizLogicAppException- BizLogicAppException
-
getStringFromCell
@Nullable public String getStringFromCell(@Nullable org.apache.poi.ss.usermodel.Cell cell, DateTimeFormatter dateTimeFormat) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException ReturnsStringformat cell value in spite of the format or value kind of the cell.- Parameters:
cell- the cell of the excel filedateTimeFormat- dateTimeFormat, may benullin which casedefaultDateTimeFormatis used.- Returns:
- the string which expresses the value of the cell.
- Throws:
jp.ecuacion.lib.core.exception.checked.BizLogicAppException- BizLogicAppException
-
openForRead
public org.apache.poi.ss.usermodel.Workbook openForRead(String filePath) throws org.apache.poi.EncryptedDocumentException, IOException Opens the excel file and returnsWorkbookobject.- Parameters:
filePath- filePath- Returns:
- workbook
- Throws:
org.apache.poi.EncryptedDocumentException- EncryptedDocumentExceptionIOException- IOException
-
getReadyToReadTableData
public <T> ExcelTable.ContextContainer getReadyToReadTableData(ExcelTableReader<T> reader, org.apache.poi.ss.usermodel.Workbook workbook, String sheetName, Integer numberOfHeaderLinesIfReadsHeaderOnlyOrNull, boolean ignoresColumnSizeSetInReader) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException Gets ready to read table data.- Parameters:
ignoresColumnSizeSetInReader- It istruemeans that even if the reader determines the column size, this method obtains all the columns as long as the header column exists.- Throws:
jp.ecuacion.lib.core.exception.checked.BizLogicAppException
-
readTableLine
public <T> List<T> readTableLine(ExcelTableReader<T> reader, ExcelTable.ContextContainer context, int rowNumber) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException Provides common procedure for read one line of a table.- Throws:
jp.ecuacion.lib.core.exception.checked.BizLogicAppException- BizLogicAppException
-
suppressesWarnLog
SetssuppressesWarnLog.- Parameters:
suppressesWarnLog- suppressesWarnLog- Returns:
ExcelTableReader<T>
-