arjansh commented on a change in pull request #230: dev/add datatypes to excel 
columns
URL: https://github.com/apache/metamodel/pull/230#discussion_r328538781
 
 

 ##########
 File path: 
excel/src/main/java/org/apache/metamodel/excel/DefaultSpreadsheetReaderDelegate.java
 ##########
 @@ -167,50 +166,114 @@ private MutableTable createTable(final Workbook wb, 
final Sheet sheet) {
                     break;
                 }
             }
-
             if (hasColumns) {
-                createColumns(table, wb, row);
+                createColumns(table, wb, row, columnTypes);
             }
         }
-
         return table;
     }
 
+    private void setColumnType(Iterator<Row> data, int rowLength, ColumnType[] 
columnTypes) {
+        while (data.hasNext()) {
+            Row row = data.next();
+            for (int index = 0; index < rowLength; index++) {
+                if (row.getLastCellNum() == 0) {
+                    continue;
+                }
+                if (row.getCell(index) == null) {
+                    columnTypes = checkColumnType(ColumnType.STRING, 
columnTypes, index);
+                } else {
+                    CellType cellType = row.getCell(index).getCellType();
+                    if (cellType.getCode() != 0 && cellType.getCode() <= 2) {
+                        columnTypes = checkColumnType(ColumnType.STRING, 
columnTypes, index);
+                    } else if (cellType.getCode() == 0) {
+                        columnTypes = 
checkColumnType((row.getCell(index).getNumericCellValue() % 1 == 0)
 
 Review comment:
   In case of a Numeric cell type, can you use some of poi's util classes to 
more specifically determine its type? E.g. `DateUtil#isCellDateFormatted(Cell)` 
to see if it's a `Date`?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to