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

           Summary: Invalid Formula cell reference when creating formula
           Product: POI
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


After filling a couple of rows with 5 columns of data I'm trying to create the
following formula that works fine in Excel:

HSSFRow r = sheet.createRow(0);

// create the IRR formula 
short col = 0;
HSSFCell c = r.createCell(col++);
c.setCellType(HSSFCell.CELL_TYPE_FORMULA);
c.setCellFormula("(1+IRR(SUMIF(A:A;ROW(INDIRECT(MIN(A:A)&\":\"&MAX(A:A)));B:B);0))^365-1");

This results in the following inlikely error:

Exception in thread "main" java.lang.IllegalArgumentException: Invalid Formula
cell reference: 'A'
        at org.apache.poi.hssf.util.CellReference.<init>(CellReference.java:48)
        at org.apache.poi.hssf.util.AreaReference.<init>(AreaReference.java:43)
        at org.apache.poi.hssf.record.formula.AreaPtg.<init>(AreaPtg.java:55)
        at
org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:290)
        at
org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:522)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:660)
        at
org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:708)
        at
org.apache.poi.hssf.model.FormulaParser.Arguments(FormulaParser.java:486)
        at
org.apache.poi.hssf.model.FormulaParser.function(FormulaParser.java:358)
        at
org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:280)
        at
org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:522)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:660)
        at
org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:708)
        at
org.apache.poi.hssf.model.FormulaParser.Arguments(FormulaParser.java:486)
        at
org.apache.poi.hssf.model.FormulaParser.function(FormulaParser.java:358)
        at
org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:280)
        at
org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:522)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:660)
        at org.apache.poi.hssf.model.FormulaParser.Add(FormulaParser.java:674)
        at
org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:710)
        at
org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:518)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:660)
        at
org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:708)
        at
org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:812)
        at
org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell.java:649)

Is there any way this formula could be created from POI?


-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to