Class ExcelTableReader<T>

java.lang.Object
jp.ecuacion.util.poi.excel.table.ExcelTable<T>
jp.ecuacion.util.poi.excel.table.reader.ExcelTableReader<T>
Type Parameters:
T - See IfExcelTable.
All Implemented Interfaces:
IfExcelTable<T>, IfExcelTableReader<T>
Direct Known Subclasses:
CellFreeExcelTableReader, CellOneLineHeaderExcelTableReader, StringExcelTableReader

public abstract class ExcelTableReader<T> extends ExcelTable<T> implements IfExcelTableReader<T>
Is a parent of excel table reader classes.
  • Field Details

    • tableRowSizeGivenByConstructor

      @Min(1L) protected @Min(1L) Integer tableRowSizeGivenByConstructor
      Is the row size of the table.

      It's equal to or greater than 1.
      0 or the number smaller than that is not acceptable.
      null is acceptable, which means tableRowSize is decided for the program to find an empty row.
      When the table has a header, the row size includes the header line,

    • tableColumnSizeGivenByConstructor

      @Min(1L) protected @Min(1L) Integer tableColumnSizeGivenByConstructor
      Is the column size of the table.

      It's equal to or greater than 1.
      0 or the number smaller than that is not acceptable.
      null is acceptable, which means tableColumnSize is decided by the length of the header. Empty header cell means it's the end of the header.
      When the table has a header, the row size includes the header line,

  • Constructor Details

  • Method Details

    • read

      @Nonnull public List<List<T>> read(@RequireNonnull String filePath) throws org.apache.poi.EncryptedDocumentException, jp.ecuacion.lib.core.exception.checked.AppException, IOException
      Reads a table data in an excel file at excelPath and Return it in the form of List<List<T>>.

      The internal List<T> stores data in one line.
      The external List stores lines of List<T>.

      Parameters:
      filePath - filePath
      Throws:
      IOException - IOException
      jp.ecuacion.lib.core.exception.checked.AppException - AppException
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
    • read

      @Nonnull public List<List<T>> read(@RequireNonnull org.apache.poi.ss.usermodel.Workbook workbook) throws org.apache.poi.EncryptedDocumentException, jp.ecuacion.lib.core.exception.checked.AppException, IOException
      Reads a table data in an excel file at filePath and Return it in the form of List<List<T>>.

      The internal List<T> stores data in one line.
      The external List stores lines of List<T>.

      Parameters:
      workbook - workbook It's used only to write down to the log so if getting the filePath is hard, filename or whatever else is fine.
      Throws:
      IOException - IOException
      jp.ecuacion.lib.core.exception.checked.AppException - AppException
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
    • getIterable

      @Nonnull public Iterable<List<T>> getIterable(@RequireNonnull org.apache.poi.ss.usermodel.Workbook workbook) throws org.apache.poi.EncryptedDocumentException, jp.ecuacion.lib.core.exception.checked.AppException, IOException
      Provides an Iterable reader.

      The internal List<T> stores data in one line.
      The external List stores lines of List<T>.

      Parameters:
      workbook - workbook It's used only to write down to the log so if getting the filePath is hard, filename or whatever else is fine.
      Throws:
      IOException - IOException
      jp.ecuacion.lib.core.exception.checked.AppException - AppException
      org.apache.poi.EncryptedDocumentException - EncryptedDocumentException
    • getTableRowSize

      @Nullable public Integer getTableRowSize()
      Returns tableRowSize, may be null.
    • getTableColumnSize

      @Nonnull public Integer getTableColumnSize(@RequireNonnull org.apache.poi.ss.usermodel.Sheet sheet, int poiBasisDeterminedTableStartRowNumber, int poiBasisDeterminedTableStartColumnNumber, boolean ignoresColumnSizeSetInReader) throws jp.ecuacion.util.poi.excel.exception.ExcelAppException
      Returns tableColumnSize.
      Parameters:
      sheet - sheet
      poiBasisDeterminedTableStartRowNumber - poiBasisDeterminedTableStartRowNumber
      poiBasisDeterminedTableStartColumnNumber - poiBasisDeterminedTableStartRowNumber
      Throws:
      jp.ecuacion.util.poi.excel.exception.ExcelAppException - ExcelAppException
    • setTableColumnSize

      public void setTableColumnSize(int tableColumnSize)
      sets tableColumnSize.

      tableColumnSize can be set by the header length, but the instance method cannot be called from constructors so the setter is needed.

      This method set the final value of the column size, so the argument is not Integer, but primitive int.

      Parameters:
      tableColumnSize - tableColumnSize.
    • getReadyToReadTableData

      public static <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.util.poi.excel.exception.ExcelAppException
      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.util.poi.excel.exception.ExcelAppException
    • ignoresAdditionalColumnsOfHeaderData

      public ExcelTableReader<T> ignoresAdditionalColumnsOfHeaderData(boolean value)
      Description copied from interface: IfExcelTable
      Stores the boolean value which indicates whether validateHeaderData ignores additional header columns.
      Specified by:
      ignoresAdditionalColumnsOfHeaderData in interface IfExcelTable<T>
      Parameters:
      value - boolean
    • isVerticalAndHorizontalOpposite

      public ExcelTableReader<T> isVerticalAndHorizontalOpposite(boolean value)
      Description copied from interface: IfExcelTable
      Decides whether header is top (normal table) or left. true means headers are at the left.
      Specified by:
      isVerticalAndHorizontalOpposite in interface IfExcelTable<T>
      Parameters:
      value - boolean
      Returns:
      IfExcelTable<T>