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 2011/10/29 12:19:09 UTC
DO NOT REPLY [Bug 52111] New: Parsing of formula with reference
intersection
https://issues.apache.org/bugzilla/show_bug.cgi?id=52111
Bug #: 52111
Summary: Parsing of formula with reference intersection
Product: POI
Version: 3.8-dev
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: dev@poi.apache.org
ReportedBy: zitzelsberger.unistuttgart@googlemail.com
Classification: Unclassified
Created attachment 27865
--> https://issues.apache.org/bugzilla/attachment.cgi?id=27865
The spreadsheetfile used.
I created a simple .xsf test spreadsheet (see attachment) that uses refernce
intersection: (C2:D3 D3:E4)
When parsing the Formula of the Cell (HSSF)
Ptg[] ptgs =
FormulaParser.parse(c.getCellFormula(),evaluationWorkbook,c.getCellType(),workbook.getSheetIndex(c.getSheet()));
The following exception is raised:
---- STACKTRACE ----
org.apache.poi.ss.formula.FormulaParseException: Parse error near char 7 'D' in
specified formula '(C2:D3 D3:E4)'. Expected ')'
at org.apache.poi.ss.formula.FormulaParser.expected(FormulaParser.java:217)
at org.apache.poi.ss.formula.FormulaParser.Match(FormulaParser.java:249)
at
org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1106)
at
org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1077)
at
org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1064)
at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1424)
at
org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1524)
at
org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1508)
at
org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1465)
at
org.apache.poi.ss.formula.FormulaParser.unionExpression(FormulaParser.java:1445)
at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1566)
at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:174)
at main.ListProtectedCells.main(ListProtectedCells.java:52)
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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 52111] Parsing of formula with reference intersection
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52111
--- Comment #1 from Matt Hillsdon <mt...@corefiling.co.uk> ---
Created attachment 30878
--> https://issues.apache.org/bugzilla/attachment.cgi?id=30878&action=edit
Proposed fix for intersections
I've been looking into intersection parsing and have attached a patch against
trunk r1525871 which I believe fixes this. I would appreciate review from
someone familiar with the formula parsing code.
There are two issues parsing "(C2:D3 D3:E4)":
(1) Intersection parsing is unsupported. It requires changing the lexing in
GetChar to track whitespace state because although we generally skip whitespace
the intersection operator is a space. This approach seems the least invasive
as it allows the rest of the parse to continue skipping whitespace.
(2) Having fixed that, brackets are not supported around expressions with lower
precedence than comparison operations (previously just union; now union and
intersection). This seems to be a matter of changing parseSimpleFactor to call
unionExpression (the root of the parse) inside the matches for parentheses.
Existing tests pass and I've added some covering the intersection and
parenthesis behaviour in TestFormulaParser.
Queries:
(a) The formula "1 2" was a tested parser fail case. It now parses as a
intersection. "1,2" already parsed as a union. Neither make sense and Excel
understandably complains. Does/should the POI FormulaParser attempt to cope
with this type of error? In a more elaborate compiler this might be a type
analysis error rather than something caught by the parse. Is there any POI
code that attempts this kind of thing?
(b) The documentation pulled in via the svn:external to
src/documentation/content/xdocs/spreadsheet/formula.xml claims intersections
and unions are not yet supported. Is the union documentation just out of date,
or is there some other sense in which it isn't supported? If it's just out of
date then I guess "Region operators: union, intersection" just wants to move
from the unsupported to the supported section. I can supply a separate patch
if required.
--
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 52111] [PATCH] Parsing of formula with reference intersection
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52111
Nick Burch <ap...@gagravarr.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |LATER
--- Comment #2 from Nick Burch <ap...@gagravarr.org> ---
In r1613737 I have added a unit test for intersect formulas, based on your
kindly provided test file
This already passes, so it looks like some other formula parser work in the
mean time has already added the required support!
(If you spot something still missing for this, please re-open the bug, and
upload a small junit unit test which shows what is still missing)
--
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 52111] [PATCH] Parsing of formula with reference intersection
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52111
Matt Hillsdon <mt...@corefiling.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Parsing of formula with |[PATCH] Parsing of formula
|reference intersection |with reference intersection
--
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