You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2018/10/22 22:03:08 UTC
[Bug 62846] New: FormulaParseException thrown for row containing
empty formula cells
https://bz.apache.org/bugzilla/show_bug.cgi?id=62846
Bug ID: 62846
Summary: FormulaParseException thrown for row containing empty
formula cells
Product: POI
Version: 4.0.0-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: valeriegryphon@gmail.com
Target Milestone: ---
I'm reading workbooks that may have been downloaded from Google sheets, so
there are errors where a formula doesn't get converted. for each cell in the
range I'm looking at, I want to display "ERROR" for cells with invalid
formulas.
I'm using lambda, so the code was essentially:
inRow.forEach(inCell -> {
if (CellType.FORMULA == inCell.getCellType()) {
try {
evaluator.evaluateInCell(inCell);
} catch (Exception ex) {
inCell.setCellType(CellType.STRING);
inCell.setCellValue("ERROR");
}
}
});
I was getting FormulaParseException thrown WITHOUT being caught!
The problem was that the value looked at by the evaluator was itself an error
message that a FormulaParseException had been thrown. With more evaluation, I
determined that the cells for which the exception was thrown were empty, and
that a single FormulaParseException was thrown to my code as part of the row
evaluation, probably dealing with the forEach invocation.
My code is now:
try {
inRow.forEach(inCell -> {
if (CellType.FORMULA == inCell.getCellType()) {
String raw = ((XSSFCell) inCell).getRawValue();
if (raw.isEmpty()) {
inCell.setCellType(CellType.STRING);
inCell.setCellValue("");
} else {
try {
evaluator.evaluateInCell(inCell);
} catch (Exception ex) {
inCell.setCellType(CellType.STRING);
inCell.setCellValue("ERROR");
}
}
});
} catch (FormulaParseException) {
// whatever....
}
I think the empty cells should be silently ignored.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 62846] FormulaParseException thrown for row containing empty
formula cells
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62846
Valerie Griffin <va...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ErrorMessage
OS| |All
CC| |valeriegryphon@gmail.com
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 62846] FormulaParseException thrown for row containing empty
formula cells
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62846
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> ---
Please attach a sample file demonstrating the problem. We will include it in
our collection of test cases.
Yegor
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org