1 package org.simantics.excel.poi.parser;
3 import org.apache.poi.ss.usermodel.Cell;
4 import org.apache.poi.ss.usermodel.Row;
6 public abstract class CellDataResolverBase<T> implements DataResolver<T> {
9 protected Double getCellNumericValue(Cell cell) {
12 switch (cell.getCellTypeEnum()) {
22 return cell.getNumericCellValue();
28 throw new RuntimeException();
31 protected String getCellStringValue(Cell cell) {
34 switch (cell.getCellTypeEnum()) {
38 return Boolean.toString(cell.getBooleanCellValue());
44 return Double.toString(cell.getNumericCellValue());
46 return cell.getStringCellValue();
50 throw new RuntimeException();
53 protected Boolean getCellBooleanValue(Cell cell) {
56 switch (cell.getCellTypeEnum()) {
60 return cell.getBooleanCellValue();
68 String value = cell.getStringCellValue();
69 if ("true".equalsIgnoreCase(value))
71 if ("1".equalsIgnoreCase(value))
78 throw new RuntimeException();
81 protected Cell getCell(Row row, int colIndex) {
82 short first = row.getFirstCellNum();
83 short last = row.getLastCellNum();
86 for (short i = first; i <= last; i++) {
87 Cell c = row.getCell(i);
90 if (c.getColumnIndex() == colIndex)