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 2012/05/02 16:43:00 UTC
[Bug 53178] New: RunTimeException: "Unexpected tAttr" in
getCellFormula()
https://issues.apache.org/bugzilla/show_bug.cgi?id=53178
Priority: P2
Bug ID: 53178
Assignee: dev@poi.apache.org
Summary: RunTimeException: "Unexpected tAttr" in
getCellFormula()
Severity: major
Classification: Unclassified
OS: Windows XP
Reporter: npaetsch@psi.de
Hardware: PC
Status: NEW
Version: 3.8
Component: HSSF
Product: POI
Created attachment 28709
--> https://issues.apache.org/bugzilla/attachment.cgi?id=28709&action=edit
Small example for the bug
Hi,
I got the following problem, I try to read the cell formula from an HSSFCell,
of cell type "HSSFCell.CELL_TYPE_FORMULA":
if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
String formula = cell.getCellFormula();
}
This all works well, unless in the attached excel sheet, where I get the
following excpetion:
Exception in thread "main" java.lang.RuntimeException: Unexpected tAttr:
org.apache.poi.ss.formula.ptg.AttrPtg []
at
org.apache.poi.ss.formula.FormulaRenderer.toFormulaString(FormulaRenderer.java:87)
at
org.apache.poi.hssf.model.HSSFFormulaParser.toFormulaString(HSSFFormulaParser.java:83)
at
org.apache.poi.hssf.usermodel.HSSFCell.getCellFormula(HSSFCell.java:628)
I don't really see the point. I assume, this is because the formula in the cell
is rather long:
=WENN('E:\Berichtswesen\Programme\pis_esm.xla'!Twert(#BEZUG!C320;"h";#BEZUG!;#BEZUG!)/1000<LTC_ENTRY_FLEX_MIN/(23+ABS(SOWI-2))*1000-1;1;WENN('E:\Berichtswesen\Programme\pis_esm.xla'!Twert(#BEZUG!C320;"h";#BEZUG!;#BEZUG!)/1000>LTC_ENTRY_FLEX_MAX/(23+ABS(SOWI-2))*1000+1;1;0))
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 53178] RunTimeException: "Unexpected tAttr" in getCellFormula()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53178
--- Comment #2 from npaetsch@psi.de ---
The exception is thrown in org.apache.poi.ss.formula.ForumlaRenderer.
When stepping through the source code while parsing the Excel-formula
{=WENN(('E:\Berichtswesen\Programme\pis_esm.xla'!Tmark($Q$12;"STD";$B$4;$B$4))
= "N";"No Allocation";"")}
as indicated in my second comment, the following stack is already set up
stack Stack<E> (id=135)
capacityIncrement 0
elementCount 2
elementData Object[10] (id=139)
[0] "(Tmark(#REF!,"STD",#REF!,#REF!))="N"" (id=143)
[1] ""No Allocation"" (id=1046)
[2] null
[3] null
[4] null
[5] null
[6] null
[7] null
[8] null
[9] null
modCount 18
The next element ptgs[13] which is of instance AttrPtg then causes the
exception.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 53178] RunTimeException: "Unexpected tAttr" in getCellFormula()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53178
--- Comment #1 from npaetsch@psi.de ---
I have to add, that the same exception occurs for the following formula:
=WENN(('E:\Berichtswesen\Programme\pis_esm.xla'!Tmark($Q$12;"STD";$B$4;$B$4)) =
"N";"No Allocation";"")
So, somehow this exception occurs due to the nested functions.
--
You are receiving this mail because:
You are the assignee for the bug.