polish
Cache FormulaEvaluator instead of creating a new one.
This commit is contained in:
committed by
Michael Minella
parent
0f513faa91
commit
371474fb48
@@ -37,6 +37,7 @@ public class PoiSheet implements Sheet {
|
||||
private final String name;
|
||||
|
||||
private int numberOfColumns = -1;
|
||||
private FormulaEvaluator evaluator;
|
||||
|
||||
/**
|
||||
* Constructor which takes the delegate sheet.
|
||||
@@ -91,8 +92,7 @@ public class PoiSheet implements Sheet {
|
||||
cells.add(cell.getStringCellValue());
|
||||
break;
|
||||
case Cell.CELL_TYPE_FORMULA:
|
||||
FormulaEvaluator evaluator = delegate.getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
cells.add(evaluator.evaluate(cell).formatAsString());
|
||||
cells.add(getFormulaEvaluator().evaluate(cell).formatAsString());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot handle cells of type " + cell.getCellType());
|
||||
@@ -101,6 +101,13 @@ public class PoiSheet implements Sheet {
|
||||
return cells.toArray(new String[cells.size()]);
|
||||
}
|
||||
|
||||
private FormulaEvaluator getFormulaEvaluator() {
|
||||
if (this.evaluator == null) {
|
||||
this.evaluator = delegate.getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
}
|
||||
return this.evaluator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user