Row row = sheet.getRow( i );
int lastCellNum = row != null ? row.getLastCellNum() : 0;
newRow( listeners, i, lastCellNum );
for ( int cellNum = 0; cellNum < lastCellNum; cellNum++ ) {
Cell cell = row.getCell( cellNum );
if ( cell == null ) {
continue;
}
double num = 0;
CellRangeAddress merged = getRangeIfMerged( cell,
mergedRanges );
int mergedColStart = DataListener.NON_MERGED;
if ( merged != null ) {
cell = sheet.getRow(merged.getFirstRow()).getCell(merged.getFirstColumn());
mergedColStart = cell.getColumnIndex();
}
switch ( cell.getCellType() ) {
case Cell.CELL_TYPE_FORMULA:
String cellValue = null;
try {
newCell(listeners,
i,
cellNum,
formatter.formatCellValue(cell, formulaEvaluator),
mergedColStart);
} catch (RuntimeException e) {
// This is thrown if an external link cannot be resolved, so try the cached value
log.warn("Cannot resolve externally linked value: " + formatter.formatCellValue(cell));
String cachedValue = tryToReadCachedValue(cell);
newCell(listeners,
i,
cellNum,
cachedValue,
mergedColStart);
}
break;
case Cell.CELL_TYPE_NUMERIC:
num = cell.getNumericCellValue();
default:
if (num - Math.round(num) != 0) {
newCell(listeners,
i,
cellNum,