More helpful exception on the wrong cell type
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693656 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a11d4082ca
commit
4782319fd1
@ -153,7 +153,7 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
|||||||
* of the old formula.
|
* of the old formula.
|
||||||
* Else if cell does not contain formula, this method leaves
|
* Else if cell does not contain formula, this method leaves
|
||||||
* the cell unchanged.
|
* the cell unchanged.
|
||||||
* Note that the same instance of HSSFCell is returned to
|
* Note that the same instance of XSSFCell is returned to
|
||||||
* allow chained calls like:
|
* allow chained calls like:
|
||||||
* <pre>
|
* <pre>
|
||||||
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
|
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
|
||||||
@ -164,16 +164,16 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
|||||||
* @param cell
|
* @param cell
|
||||||
*/
|
*/
|
||||||
public XSSFCell evaluateInCell(Cell cell) {
|
public XSSFCell evaluateInCell(Cell cell) {
|
||||||
if (cell == null) {
|
doEvaluateInCell(cell);
|
||||||
return null;
|
return (XSSFCell)cell;
|
||||||
}
|
}
|
||||||
XSSFCell result = (XSSFCell) cell;
|
protected void doEvaluateInCell(Cell cell) {
|
||||||
|
if (cell == null) return;
|
||||||
if (cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA) {
|
if (cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA) {
|
||||||
CellValue cv = evaluateFormulaCellValue(cell);
|
CellValue cv = evaluateFormulaCellValue(cell);
|
||||||
setCellType(cell, cv); // cell will no longer be a formula cell
|
setCellType(cell, cv); // cell will no longer be a formula cell
|
||||||
setCellValue(cell, cv);
|
setCellValue(cell, cv);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
private static void setCellType(Cell cell, CellValue cv) {
|
private static void setCellType(Cell cell, CellValue cv) {
|
||||||
int cellType = cv.getCellType();
|
int cellType = cv.getCellType();
|
||||||
|
Loading…
Reference in New Issue
Block a user