I've been looking for that for a couple of days now. how embarrassing. thanks,

Lloyd


Zach Engel wrote:
The line of code you specified is missing ) at the end

cell.setCellFormula("SUM(C2:C10");


is that the issue?

-----Original Message-----
From: Lloyd H. Meinholz [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 6:42 PM
To: POI Users List
Subject: Re: setCellFormula() quest

yes, a little different. my formula is "SUM(D2:D10)". This seems to work with int, but not decimals. I tried summing some of the columns that were int only and the Sum worked, but when a column has decimal points, it didn't. Funny thing is, I tried a simple test similar to what you've done and it works. I can't figure out what is different.

The line of code that causes the error is:
cell.setCellFormula("SUM(C2:C10");

The error I get is runtime error:

Error: Integer Expected
Exception in thread "main" java.lang.RuntimeException: Cannot Parse, sorry : Integer Expected at org.apache.poi.hssf.model.FormulaParser.Abort(FormulaParser.java:117) at org.apache.poi.hssf.model.FormulaParser.Expected(FormulaParser.java:124) at org.apache.poi.hssf.model.FormulaParser.GetNum(FormulaParser.java:239) at org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:479) at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:548) at org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:596) at org.apache.poi.hssf.model.FormulaParser.Arguments(FormulaParser.java:453) at org.apache.poi.hssf.model.FormulaParser.function(FormulaParser.java:315) at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:265) at org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:474) at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:548) at org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:596) at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:700) at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell.java:678)

A simplification of my sheet seems to work, so maybe I'm messing up somewhere. I'm trying to go through it now. Thanks for the help,

Lloyd


Amol Deshmukh wrote:

Lloyd,

The following code works for me:

<code>
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class SimpleTest {
   public static void main(String[] args) throws Exception {
       HSSFWorkbook workbook = new HSSFWorkbook();
       HSSFCell cell =
workbook.createSheet().createRow(0).createCell((short) 0);
       cell.setCellFormula("SUM(1.5,2.3333)");
       workbook.write(new FileOutputStream("Simple.xls"));
   }
}
</code>

Are you trying something along different lines? What is the exact nature of the problem you are facing (exception/unexpected results)?

~ amol





-----Original Message-----
From: Lloyd H. Meinholz [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 17, 2005 9:37 AM
To: [email protected]
Subject: setCellFormula() quest


Is there a way to use setCellFormula() when the cell values included in the formula are non integer numeric values (ex. 3.5)?

I seem to be able to get setCellFormula() to work with int's but not other numeric types. If not, is it really difficult to add that support or should it be relatively easy? Thanks,

Lloyd

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to