The following snippet of code will fail: FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); evaluator.evaluate(source) workbook is of type org.apache.poi.ss.usermodel.Workbook source is of type org.apache.poi.ss.usermodel.Cell with the following formula: =SUM(1+ 2) Here's the exception: Caught: org.apache.poi.ss.formula.FormulaParseException: Parse error near char 6 ' ' in specified formula 'SUM(1+ 2)'. Expected cell ref or constant literal
Are newlines really valid characters within the formula though? Are you creating the formula with the newline it in through POI or excel?
Created attachment 26388 [details] Test spreadsheet for newline in formula error
Created attachment 26389 [details] Groovy test harness for newline in formula error
(In reply to comment #1) > Are newlines really valid characters within the formula though? > > Are you creating the formula with the newline it in through POI or excel? New lines (created using alt+enter in formula bar on Windows Excel 2010 OR command+option+return in Mac Office 2008) are valid, i.e. Excel correctly calculates the formula. I created the formula using Excel and used Apache POI to read the workbook. I attached a test harness in Groovy and a spreadsheet (xlsx) that has new line chars in the formula. Cheers, Tommy.
It looks like you can only have the newline in .xlsx files - when I save as a .xls and re-open then the newline has gone If you can create a .xls file with the newlines, please upload it Otherwise, I'm going to work on the basis that this is a .xlsx only feature and try to fix it as that.
On the basis that this is a XSSF (.xlsx) only feature), then the newlines can't be turned into Ptgs so we don't need them when doing the Ptg parsing. As such, fixed in r1045021 by stripping them out during the XSSF Ptg step.
(In reply to comment #6) > On the basis that this is a XSSF (.xlsx) only feature), then the newlines can't > be turned into Ptgs so we don't need them when doing the Ptg parsing. As such, > fixed in r1045021 by stripping them out during the XSSF Ptg step. Awesome, that was real quick. I should've mentioned that this problem happens in XSSF only, I couldn't replicate the problem in HSSF. So when is the next stable release (assume it's 3.8) coming? Where can I download the nightly builds?