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