Class ExcelTableReader<T>
- Type Parameters:
T- SeeIfExcelTable.
- All Implemented Interfaces:
IfExcelTable<T>,IfExcelTableReader<T>
- Direct Known Subclasses:
CellFreeExcelTableReader,CellOneLineHeaderExcelTableReader,StringExcelTableReader
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvidesIterable.static classProvides Iterator.Nested classes/interfaces inherited from class jp.ecuacion.util.poi.excel.table.ExcelTable
ExcelTable.ContextContainer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Min(1L) IntegerIs the column size of the table.protected @Min(1L) IntegerIs the row size of the table.Fields inherited from class jp.ecuacion.util.poi.excel.table.ExcelTable
ignoresAdditionalColumnsOfHeaderData, isVerticalAndHorizontalOpposite, sheetName, tableStartColumnNumber, tableStartRowNumber -
Constructor Summary
ConstructorsConstructorDescriptionExcelTableReader(String sheetName, Integer tableStartRowNumber, int tableStartColumnNumber, Integer tableRowSize, Integer tableColumnSize) Constructs a new instance with the sheet name, the position and the size of the excel table. -
Method Summary
Modifier and TypeMethodDescriptiongetIterable(org.apache.poi.ss.usermodel.Workbook workbook) Provides anIterablereader.static <T> ExcelTable.ContextContainergetReadyToReadTableData(ExcelTableReader<T> reader, org.apache.poi.ss.usermodel.Workbook workbook, String sheetName, int tableStartColumnNumber, Integer numberOfHeaderLinesIfReadsHeaderOnlyOrNull, boolean ignoresColumnSizeSetInReader) Gets ready to read table data.getTableColumnSize(org.apache.poi.ss.usermodel.Sheet sheet, int poiBasisDeterminedTableStartRowNumber, int poiBasisDeterminedTableStartColumnNumber, boolean ignoresColumnSizeSetInReader) Returns tableColumnSize.Returns tableRowSize, may benull.ignoresAdditionalColumnsOfHeaderData(boolean value) Stores the boolean value which indicates whethervalidateHeaderDataignores additional header columns.isVerticalAndHorizontalOpposite(boolean value) Decides whether header is top (normal table) or left.Reads a table data in an excel file atexcelPathand Return it in the form ofList<List<T>>.read(org.apache.poi.ss.usermodel.Workbook workbook) Reads a table data in an excel file atfilePathand Return it in the form ofList<List<T>>.voidsetTableColumnSize(int tableColumnSize) setstableColumnSize.Methods inherited from class jp.ecuacion.util.poi.excel.table.ExcelTable
getPoiBasisDeterminedTableStartColumnNumber, getPoiBasisDeterminedTableStartRowNumber, getSheetName, ignoresAdditionalColumnsOfHeaderData, isVerticalAndHorizontalOppositeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jp.ecuacion.util.poi.excel.table.IfExcelTable
getFarLeftAndTopHeaderLabel, getHeaderLabelData, getNumberOfHeaderLines, getSheetName, getStringValue, ignoresAdditionalColumnsOfHeaderData, isVerticalAndHorizontalOppositeMethods inherited from interface jp.ecuacion.util.poi.excel.table.reader.IfExcelTableReader
getCellData, isCellDataEmpty, updateAndGetHeaderData, validateHeaderData
-
Field Details
-
tableRowSizeGivenByConstructor
Is the row size of the table.It's equal to or greater than
1.
0or the number smaller than that is not acceptable.
nullis acceptable, which meanstableRowSizeis decided for the program to find an empty row.
When the table has a header, the row size includes the header line, -
tableColumnSizeGivenByConstructor
Is the column size of the table.It's equal to or greater than
1.
0or the number smaller than that is not acceptable.
nullis acceptable, which meanstableColumnSizeis 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
-
ExcelTableReader
public ExcelTableReader(@RequireNonnull String sheetName, @Nullable Integer tableStartRowNumber, int tableStartColumnNumber, @Nullable Integer tableRowSize, @Nullable Integer tableColumnSize) Constructs a new instance with the sheet name, the position and the size of the excel table.- Parameters:
sheetName- SeeExcelTable.sheetName.tableStartRowNumber- SeeExcelTable.tableStartRowNumber.tableStartColumnNumber- SeeExcelTable.tableStartColumnNumber.tableRowSize- SeetableRowSizeGivenByConstructor.tableColumnSize- SeetableColumnSizeGivenByConstructor.
-
-
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 atexcelPathand Return it in the form ofList<List<T>>.The internal
List<T>stores data in one line.
The externalListstores lines ofList<T>.- Parameters:
filePath- filePath- Throws:
IOException- IOExceptionjp.ecuacion.lib.core.exception.checked.AppException- AppExceptionorg.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 atfilePathand Return it in the form ofList<List<T>>.The internal
List<T>stores data in one line.
The externalListstores lines ofList<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- IOExceptionjp.ecuacion.lib.core.exception.checked.AppException- AppExceptionorg.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 anIterablereader.The internal
List<T>stores data in one line.
The externalListstores lines ofList<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- IOExceptionjp.ecuacion.lib.core.exception.checked.AppException- AppExceptionorg.apache.poi.EncryptedDocumentException- EncryptedDocumentException
-
getTableRowSize
Returns tableRowSize, may benull. -
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- sheetpoiBasisDeterminedTableStartRowNumber- poiBasisDeterminedTableStartRowNumberpoiBasisDeterminedTableStartColumnNumber- poiBasisDeterminedTableStartRowNumber- Throws:
jp.ecuacion.util.poi.excel.exception.ExcelAppException- ExcelAppException
-
setTableColumnSize
public void setTableColumnSize(int tableColumnSize) setstableColumnSize.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 primitiveint.- 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 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.util.poi.excel.exception.ExcelAppException
-
ignoresAdditionalColumnsOfHeaderData
Description copied from interface:IfExcelTableStores the boolean value which indicates whethervalidateHeaderDataignores additional header columns.- Specified by:
ignoresAdditionalColumnsOfHeaderDatain interfaceIfExcelTable<T>- Parameters:
value- boolean
-
isVerticalAndHorizontalOpposite
Description copied from interface:IfExcelTableDecides whether header is top (normal table) or left.truemeans headers are at the left.- Specified by:
isVerticalAndHorizontalOppositein interfaceIfExcelTable<T>- Parameters:
value- boolean- Returns:
IfExcelTable<T>
-