https://bz.apache.org/bugzilla/show_bug.cgi?id=60355

            Bug ID: 60355
           Summary: SS Formula Parser fails to parse valid formula string
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: SS Common
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 34430
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34430&action=edit
Excel workbook used by the test program

SS Formula Parser is unable to parse valid Excel formula string.

Here's the stack trace --

org.apache.poi.ss.formula.FormulaParseException: Unused input
[("HSACTIVE","Year#Jan","Measures#Sales","Product#Cola","Market#New
York","Scenario#Actual")] after attempting to parse the formula
[[1]!HsGetValue("HSACTIVE","Year#Jan","Measures#Sales","Product#Cola","Market#New
York","Scenario#Actual")]
        at
org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1653)
        at
org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:159)
        at org.apache.poi.xssf.usermodel.XSSFCell.setFormula(XSSFCell.java:553)
        at
org.apache.poi.xssf.usermodel.XSSFCell.setCellFormula(XSSFCell.java:533)
        at HsGetValTest.main(HsGetValTest.java:28)

HsGetVal is a valid XLA Add-In formula. Excel is able to read and parse without
problems.

Here's my standalone Java test sample

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

import com.fasterxml.jackson.databind.exc.InvalidFormatException;

public class HsGetValTest {
    public static void main( String[] args ) {

        String fileName = "HsGetVal.xlsx";

        File workbookFile = new File( fileName ) ;

        try {
            FileInputStream fis = new FileInputStream(workbookFile);
            Workbook workbook = WorkbookFactory.create(fis);

            Sheet sheet = workbook.getSheetAt(workbook.getActiveSheetIndex());
            Cell formulaCell = sheet.getRow(4).getCell(1);
            String cellFormula = formulaCell.getCellFormula();
            System.out.println("cell formula:" + cellFormula);
            formulaCell.setCellFormula(cellFormula);

        } catch( FileNotFoundException e ) {
            e.printStackTrace();
        } catch( InvalidFormatException e ) {
            e.printStackTrace();
        } catch( IOException e ) {
            e.printStackTrace();
        } catch( Exception e) {
                e.printStackTrace();
        }
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to