You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Harsh <hu...@nimaya.com> on 2003/02/21 06:10:34 UTC

Formula and Excel

Hi,
            Suppose we have following values for our excel file.
Cell A2 = 10 , Cell A3 = 5
Cell A1 (formula Cell)-   
            Formula : A2+A3
            Value    : 15
 
Now , we change the value of A3 = 6.
 
Using Java , I interpret my formula A2+A3 and come up with Answer 16
 
I want to change Value of Cell A1 from 15  -> 16. So I execute following
statement.
 
cell.setCellValue(16);
 
But it is not allowing me to do this. Giving me following exception
 
Exception in thread "main" java.lang.ClassCastException:
org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate
        at
org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(HSSFCell.java:632)
        at POIExample2.main(POIExample2.java:63) 
                        
                        What Should I do set New Value (16 in my case) ,
in the Cell A1.
 
Looking forward for  Group's Comments
 
Regards,
Harsh Ubriani
Nimaya Technologies

RE: Formula and Excel

Posted by Harsh <hu...@nimaya.com>.
I am working on Unix Platform. So Excel can't do calculations for me.
I am taking inputs from JSP page and inserting that inputs into Excel
File.
After Inserting inputs into Excel File, I need to calculate values of
Formulas and modify Results.

-----Original Message-----
From: Steve [mailto:stephen@Basit.COM] 
Sent: Friday, February 21, 2003 6:17 PM
To: POI Users List
Subject: Re: Formula and Excel

why would you want to change the cell value of the sum;
Excel will do that for you automatically, since there
is a formula in that cell.
i think you got an exception because the cell had stored
a formula (likely a String) and you set it to a 
numeric value.

----- Original Message ----- 
From: "Harsh" <hu...@nimaya.com>
To: <po...@jakarta.apache.org>
Sent: Friday, February 21, 2003 12:10 AM
Subject: Formula and Excel


> Hi,
>             Suppose we have following values for our excel file.
> Cell A2 = 10 , Cell A3 = 5
> Cell A1 (formula Cell)-   
>             Formula : A2+A3
>             Value    : 15
>  
> Now , we change the value of A3 = 6.
>  
> Using Java , I interpret my formula A2+A3 and come up with Answer 16
>  
> I want to change Value of Cell A1 from 15  -> 16. So I execute
following
> statement.
>  
> cell.setCellValue(16);
>  
> But it is not allowing me to do this. Giving me following exception
>  
> Exception in thread "main" java.lang.ClassCastException:
> org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate
>         at
> org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(HSSFCell.java:632)
>         at POIExample2.main(POIExample2.java:63) 
>                         
>                         What Should I do set New Value (16 in my case)
,
> in the Cell A1.
>  
> Looking forward for  Group's Comments
>  
> Regards,
> Harsh Ubriani
> Nimaya Technologies
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org



Re: Formula and Excel

Posted by Steve <st...@Basit.COM>.
why would you want to change the cell value of the sum;
Excel will do that for you automatically, since there
is a formula in that cell.
i think you got an exception because the cell had stored
a formula (likely a String) and you set it to a 
numeric value.

----- Original Message ----- 
From: "Harsh" <hu...@nimaya.com>
To: <po...@jakarta.apache.org>
Sent: Friday, February 21, 2003 12:10 AM
Subject: Formula and Excel


> Hi,
>             Suppose we have following values for our excel file.
> Cell A2 = 10 , Cell A3 = 5
> Cell A1 (formula Cell)-   
>             Formula : A2+A3
>             Value    : 15
>  
> Now , we change the value of A3 = 6.
>  
> Using Java , I interpret my formula A2+A3 and come up with Answer 16
>  
> I want to change Value of Cell A1 from 15  -> 16. So I execute following
> statement.
>  
> cell.setCellValue(16);
>  
> But it is not allowing me to do this. Giving me following exception
>  
> Exception in thread "main" java.lang.ClassCastException:
> org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate
>         at
> org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(HSSFCell.java:632)
>         at POIExample2.main(POIExample2.java:63) 
>                         
>                         What Should I do set New Value (16 in my case) ,
> in the Cell A1.
>  
> Looking forward for  Group's Comments
>  
> Regards,
> Harsh Ubriani
> Nimaya Technologies
>