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/09/22 22:24:16 UTC

DO NOT REPLY [Bug 51875] New: Newline characters in shared formulas for XLSX sheets results in FormulaParseException

https://issues.apache.org/bugzilla/show_bug.cgi?id=51875

             Bug #: 51875
           Summary: Newline characters in shared formulas for XLSX sheets
                    results in FormulaParseException
           Product: POI
           Version: 3.8-dev
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: marcel.may.de@gmail.com
    Classification: Unclassified


Created attachment 27570
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27570
Updated test-data/spreadsheet/NewlineInFormulas.xlsx containing shared formula
with newline to trigger exception

When a shared formular in a XLSM sheet contains a newline ('\r\n') character
POI throws an exception:

org.apache.poi.ss.formula.FormulaParseException: Unused input [
+B2] after attempting to parse the formula [B1
+B2]
    at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1571)
    at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:174)
    at
org.apache.poi.xssf.usermodel.XSSFCell.convertSharedFormula(XSSFCell.java:396)
    at org.apache.poi.xssf.usermodel.XSSFCell.getCellFormula(XSSFCell.java:368)
    at
org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook.getFormulaTokens(XSSFEvaluationWorkbook.java:150)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:281)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:225)
    at
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateFormulaCellValue(XSSFFormulaEvaluator.java:264)
    at
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateFormulaCell(XSSFFormulaEvaluator.java:151)
    at
org.apache.poi.xssf.usermodel.TestXSSFBugs.test50440(TestXSSFBugs.java:637)
   ...

My proposed fix modifies the formula parser to treat newlines like whitespaces
(which get skipped and therefore will prevent the parser to 'throw up' when
encountering newlines).

This makes a previous workaround obsolete (see
https://issues.apache.org/bugzilla/show_bug.cgi?id=50440).

Patch will follow.

Cheers,
Marcel

-- 
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


DO NOT REPLY [Bug 51875] Newline characters in shared formulas for XLSX sheets results in FormulaParseException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51875

--- Comment #1 from Marcel May <ma...@gmail.com> 2011-09-22 20:32:51 UTC ---
Created attachment 27571
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27571
Fixes FormularParser, extends the TestXSSFBugs test case, and reverts the
previous and obsolete workaround from #50440

-- 
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


DO NOT REPLY [Bug 51875] [PATCH] Newline characters in shared formulas for XLSX sheets results in FormulaParseException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51875

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #2 from Nick Burch <ni...@alfresco.com> 2011-12-05 00:52:48 UTC ---
Thanks for this, patch applied in r1210299.

-- 
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


DO NOT REPLY [Bug 51875] [PATCH] Newline characters in shared formulas for XLSX sheets results in FormulaParseException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51875

Marcel May <ma...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marcel.may.de@gmail.com

-- 
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


DO NOT REPLY [Bug 51875] [PATCH] Newline characters in shared formulas for XLSX sheets results in FormulaParseException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51875

Marcel May <ma...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Newline characters in       |[PATCH] Newline characters
                   |shared formulas for XLSX    |in shared formulas for XLSX
                   |sheets results in           |sheets results in
                   |FormulaParseException       |FormulaParseException
         OS/Version|                            |All

-- 
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