Bug 49725 - org.apache.poi.ss.formula.FormulaParseException on valid names in formula, with "6_" in name
Summary: org.apache.poi.ss.formula.FormulaParseException on valid names in formula, wi...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-08 21:00 UTC by Tony Harvey
Modified: 2010-08-12 11:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Harvey 2010-08-08 21:00:18 UTC
I have an excel file merge program that is experiencing a FormulaParseException when copying valid formula to a new workbook.
I believe it is a parser bug when the name contains a digit followed by an underscore. See the program output at the end.
The program flow is:
1. create new empty sheets with same names in target workbook
2. copy Name definitions from source workbook
3. copy cells' contents, including formulae from old sheet to new sheet
If I change the Name names to remove the digit/underscore condition the exception does not occur. e.g. if the name "DA6_LEO_WBS_Number" is changed to "DA6xLEO_WBS_Number" then the program continues to successful completion. I have a workaround that changes the Name names when copyinf Name definitions and making the Name references in formulae when copying cells.
------------------------------------output-------------------------
copying name DA6_LEO_WBS_Number as 'DA6 LEO WBS MOPDR'!$A$1:$A$24
Copying data for sheet DA6 LEO WBS MOPDR
Copying data for sheet DA6 LEO Mat MOPDR
Exception in thread "main" org.apache.poi.ss.formula.FormulaParseException: Parse error near char 9 '_' in specified formula 'INDEX(DA6_LEO_WBS_Name,MATCH($A3,DA6_LEO_WBS_Number,0))'. Expected ',' or ')'
        at org.apache.poi.ss.formula.FormulaParser.expected(FormulaParser.java:217)
        at org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1049)
        at org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:929)
        at org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:551)
        at org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:423)
        at org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:266)
        at org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1112)
        at org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1072)
        at org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1059)
        at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1410)
        at org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1510)
        at org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1494)
        at org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1451)
        at org.apache.poi.ss.formula.FormulaParser.unionExpression(FormulaParser.java:1431)
        at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1552)
        at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:174)
        at org.apache.poi.hssf.model.HSSFFormulaParser.parse(HSSFFormulaParser.java:72)
        at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell.java:588)
        at workbookmerge.ExcelUtil.copyCell(ExcelUtil.java:124)
        at workbookmerge.ExcelUtil.copyRow(ExcelUtil.java:58)
        at workbookmerge.ExcelUtil.copySheets(ExcelUtil.java:35)
        at workbookmerge.ExcelUtil.copySheets(ExcelUtil.java:23)
        at workbookmerge.Main.main(Main.java:166)
Comment 1 Yegor Kozlov 2010-08-12 11:15:08 UTC
Fixed in r984823.

Junit added. 

Yegor