Class ExcelReadUtil
java.lang.Object
jp.ecuacion.util.poi.excel.util.ExcelReadUtil
Provides excel reading related
apache POI utility methods.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetNoDataStringIfNoData(String value, String noDataString) Returns properNoDataStringvalue if the argument value isnullor"", otherwize returns the argument value.static StringgetStringFromCell(org.apache.poi.ss.usermodel.Cell cell) ReturnsStringformat cell value in spite of the format or value kind of the cell.static StringgetStringFromCell(org.apache.poi.ss.usermodel.Cell cell, String filename) ReturnsStringformat cell value in spite of the format or value kind of the cell.static StringgetStringFromCell(org.apache.poi.ss.usermodel.Cell cell, String filename, DateTimeFormatter dateTimeFormat) ReturnsStringformat cell value in spite of the format or value kind of the cell.static StringgetStringFromCell(org.apache.poi.ss.usermodel.Cell cell, String filename, DateTimeFormatter dateTimeFormat, String noDataString) ReturnsStringformat cell value in spite of the format or value kind of the cell.static org.apache.poi.ss.usermodel.WorkbookopenForRead(String filePath) Opens the excel file and returnsWorkbookobject.
-
Method Details
-
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 static String getStringFromCell(@Nullable org.apache.poi.ss.usermodel.Cell cell) throws jp.ecuacion.util.poi.excel.exception.ExcelAppException 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.util.poi.excel.exception.ExcelAppException- ExcelAppException
-
getStringFromCell
@Nullable public static String getStringFromCell(@Nullable org.apache.poi.ss.usermodel.Cell cell, @Nullable String filename) throws jp.ecuacion.util.poi.excel.exception.ExcelAppException ReturnsStringformat cell value in spite of the format or value kind of the cell.- Parameters:
cell- the cell of the excel filefilename- Used for error message, may benullin which case the error message shows no filename.- Returns:
- the string which expresses the value of the cell.
- Throws:
jp.ecuacion.util.poi.excel.exception.ExcelAppException- ExcelAppException
-
getStringFromCell
@Nullable public static String getStringFromCell(@Nullable org.apache.poi.ss.usermodel.Cell cell, @Nullable String filename, DateTimeFormatter dateTimeFormat) throws jp.ecuacion.util.poi.excel.exception.ExcelAppException ReturnsStringformat cell value in spite of the format or value kind of the cell.return value when row is null or cell is null, etc... is null.
- Parameters:
cell- the cell of the excel filefilename- Used for error message, may benullin which case the error message shows no filename.dateTimeFormat- dateTimeFormat, may benullin which casedefaultDateTimeFormatis used.- Returns:
- the string which expresses the value of the cell.
- Throws:
jp.ecuacion.util.poi.excel.exception.ExcelAppException- ExcelAppException
-
getStringFromCell
@Nullable public static String getStringFromCell(@Nullable org.apache.poi.ss.usermodel.Cell cell, @Nullable String filename, DateTimeFormatter dateTimeFormat, String noDataString) throws jp.ecuacion.util.poi.excel.exception.ExcelAppException ReturnsStringformat cell value in spite of the format or value kind of the cell.- Parameters:
cell- the cell of the excel filefilename- Used for error message, may benullin which case the error message shows no filename.dateTimeFormat- dateTimeFormat, may benullin which casedefaultDateTimeFormatis used.noDataString- return value when row is null or cell is null, etc...- Returns:
- the string which expresses the value of the cell.
- Throws:
jp.ecuacion.util.poi.excel.exception.ExcelAppException- ExcelAppException
-
openForRead
public static 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
-