Class ExcelReadUtil

java.lang.Object
jp.ecuacion.util.poi.excel.util.ExcelReadUtil

public class ExcelReadUtil extends Object
Provides excel reading related apache POI utility methods.
  • Constructor Details

    • ExcelReadUtil

      public ExcelReadUtil()
      Constructs a new instance with NoDataString = NULL.

      NoDataString = NULL is recommended. See NoDataString.

    • ExcelReadUtil

      public ExcelReadUtil(@Nonnull NoDataString noDataString)
      Constructs a new instance with designated NoDataString.

      NoDataString = NULL is recommended. See NoDataString.

      Parameters:
      noDataString - noDataString
  • Method Details

    • setDefaultDateTimeFormat

      public void setDefaultDateTimeFormat(DateTimeFormatter dateTimeFormat)
      Sets defaultDateTimeFormat.
      Parameters:
      dateTimeFormat - dateTimeFormat
    • getNoDataStringIfNoData

      @Nullable public String getNoDataStringIfNoData(@Nullable String value)
      Returns proper NoDataString value if the argument value is null or "", otherwize returns the argument value.
      Parameters:
      value - value, may be null.
      Returns:
      the argument value or the empty string designated by noDataString when 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
      Returns String format 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
      Returns String format cell value in spite of the format or value kind of the cell.
      Parameters:
      cell - the cell of the excel file
      dateTimeFormat - dateTimeFormat, may be null in which case defaultDateTimeFormat is 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 returns Workbook object.
      Parameters:
      filePath - filePath
      Returns:
      workbook
      Throws:
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
      IOException - IOException
    • getReadyToReadTableData

      public <T> ExcelTable.ContextContainer getReadyToReadTableData(ExcelTableReader<T> reader, org.apache.poi.ss.usermodel.Workbook workbook, String sheetName, int tableStartColumnNumber, Integer numberOfHeaderLinesIfReadsHeaderOnlyOrNull, boolean ignoresColumnSizeSetInReader) throws jp.ecuacion.lib.core.exception.checked.BizLogicAppException
      Gets ready to read table data.
      Parameters:
      ignoresColumnSizeSetInReader - It is true means 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

      public ExcelReadUtil suppressesWarnLog(boolean suppressesWarnLog)
      Sets suppressesWarnLog.
      Parameters:
      suppressesWarnLog - suppressesWarnLog
      Returns:
      ExcelTableReader<T>