arjansh commented on a change in pull request #230: dev/add datatypes to excel
columns
URL: https://github.com/apache/metamodel/pull/230#discussion_r330052845
##########
File path:
excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
##########
@@ -169,21 +182,84 @@ private MutableTable createTable(final Workbook wb,
final Sheet sheet) {
}
if (hasColumns) {
- createColumns(table, wb, row);
+ createColumns(table, wb, row, columnTypes);
}
}
return table;
}
+ private ColumnType[] getColumnTypes(final Sheet sheet, final Row row) {
+ final Iterator<Row> data = ExcelUtils.getRowIterator(sheet,
_configuration, false);
+ final int rowLength = row.getLastCellNum();
+ int eagerness = ExcelConfiguration.EAGER_READ;
+ final ColumnType[] columnTypes = new ColumnType[rowLength];
+
+ while (data.hasNext() && eagerness-- > 0) {
+ final Row currentRow = data.next();
+ if (currentRow.getRowNum() <
_configuration.getColumnNameLineNumber()) {
+ continue;
+ }
+ for (int index = 0; index < rowLength; index++) {
+ if (currentRow.getLastCellNum() == 0) {
+ continue;
+ }
+ columnTypes[index] = getColumnTypeFromRow(columnTypes[index],
currentRow, index);
Review comment:
I like it better if you don't pass the current value of the columnType at
the current index into the `getColumnTypeFromRow` method. I would move the
logic from the `checkColumnType(ColumnType, ColumnType) here, so that method
can be removed and the `getColumnTypeFromRow` just returns the ColumnType it
determines for its inspected cell.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services