Hi All,
 
I could resolve the problem of runtime exception by removing single quote (java.lang.RuntimeException: Cannot Parse, sorry : Integer Expected ). Now I am getting StringIndexOutOfBoundsException when trying to apply the same sheet reference formula.
---------------------------------------------------------------------------------
String strFormulas = "SUM(Sheet1!B12,Sheet2!B12)" ;
objCell.setCellFormula(strFormulas);
--------------------------------------------------------------------------------
 
 
---------------------- STACK TRACE  -----------------------------------------------
 

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:507)
        at org.apache.poi.hssf.util.CellReference.<init>(CellReference.java:81)
        at org.apache.poi.hssf.record.formula.ReferencePtg.<init>(ReferencePtg.j
ava:94)
        at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:310)
 
        at org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:487
)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:545)
        at org.apache.poi.hssf.model.FormulaParser._expression_(FormulaParser.java
:596)
        at org.apache.poi.hssf.model.FormulaParser.Arguments(FormulaParser.java:
462)
        at org.apache.poi.hssf.model.FormulaParser.function(FormulaParser.java:3
34)
        at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:284)
 
        at org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:487
)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:545)
        at org.apache.poi.hssf.model.FormulaParser._expression_(FormulaParser.java
:596)
        at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:701)
 
        at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell.java:7
15)
        at com.pg.psf.util.ExcelWriter.writeToExcel(E:/JRUN4/servers/PSF/default
-ear/default-war/WEB-INF/src/com/pg/psf/util/ExcelWriter.java:333)
 
------------------ STACK TRACE -----------------------------
 
Can anyone pls help me with this.
 
Thanks in advance
 
-Anant Sagar
----- Original Message -----
Sent: Saturday, December 13, 2003 3:08 PM
Subject: HSSF: Sheet Reference Formula not working

Hi All,
 
Need Help!
 
When I am trying to set a sheet reference formula to a cell, I get the 'Integer Expected' error.
I m using latest POI version i.e. "poi-2.0-RC1-20031102".

I am trying to create a formula in Sheet 3 to sum Sheet1:Cell B12 and Sheet2:Cell.Here is the code where it originates.
I tried by putting = sign before formula, this also does'nt work. The same formula works if i paste on excel cell manually.
 
-------------------------------------------------------
String strFormulas = "SUM('Sheet1'!B12,'Sheet2'!B12)" ;
objCell.setCellFormula(strFormulas);
-------------------------------------------------------
 
Here is the stacktrace-------
 
Error: Integer Expected
java.lang.RuntimeException: Cannot Parse, sorry : Integer Expected
        at org.apache.poi.hssf.model.FormulaParser.Abort(FormulaParser.java:154)
 
        at org.apache.poi.hssf.model.FormulaParser.Expected(FormulaParser.java:1
61)
        at org.apache.poi.hssf.model.FormulaParser.GetNum(FormulaParser.java:258
)
        at org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:492
)
        at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:545)
        at org.apache.poi.hssf.model.FormulaParser._expression_(FormulaParser.java
:596)
        at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:701)
 
        at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell.java:7
15)
        at com.pg.psf.util.ExcelWriter.writeToExcel(E:/JRUN4/servers/PSF/default
-ear/default-war/WEB-INF/src/com/pg/psf/util/ExcelWriter.java:318)
 

Does someone know how to solve this problem. Pls. let me know.
 
-Anant Sagar


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to