You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Nouman Shaikh <no...@yahoo.com> on 2006/11/16 11:29:48 UTC

How to evaluate the formula with multiple sheet reference.

HI,

I am using HSSFFormulaEvaluator, and I am facing two problems:

1. HSSFFormulaEvaluator.evaluateInCell(); is giving me "ClassCastException".
I am using the following code 

----------------
            /////formula Code//////
            HSSFFormulaEvaluator form1 = new
HSSFFormulaEvaluator(sheet1,wb);

            CellReference cellRef1 = new CellReference("C2");
            HSSFRow row = sheet1.getRow(cellRef1.getRow());
            form1.setCurrentRow(row);
            HSSFCell cell = row.getCell(cellRef1.getCol());

            form1.evaluateInCell(cell);
--------------
the formula in cell C2 is 'A1*B1'. When it executes the line
"form1.evaluateInCell(cell);" it raises "ClassCastException". This code is
working fine with HSSFFormulaEvaluator.evaluate() method.

2. My second problem is that, how can I evaluate the formula, which refer
some other sheet. e.g. =A1 * Sheet2!B1. I am trying to evaluate this formula
with the HSSFFormulaEvaluator.evaluate() method but it does not work. It
always return me the value of cell A1. (I am using the same code as written
above for this also).

Plz help me I am in very serious trouble.

Thanx 

Nouman

-- 
View this message in context: http://www.nabble.com/How-to-evaluate-the-formula-with-multiple-sheet-reference.-tf2642069.html#a7375107
Sent from the POI - User mailing list archive at Nabble.com.


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


Re: How to evaluate the formula with multiple sheet reference.

Posted by de...@yahoo.com.
Both problems are now fixed in the latest code in SVN.

--- Nouman Shaikh <no...@yahoo.com> wrote:

> 
> HI,
> 
> I am using HSSFFormulaEvaluator, and I am facing two
> problems:
> 
> 1. HSSFFormulaEvaluator.evaluateInCell(); is giving
> me "ClassCastException".
> I am using the following code 
> 
> ----------------
>             /////formula Code//////
>             HSSFFormulaEvaluator form1 = new
> HSSFFormulaEvaluator(sheet1,wb);
> 
>             CellReference cellRef1 = new
> CellReference("C2");
>             HSSFRow row =
> sheet1.getRow(cellRef1.getRow());
>             form1.setCurrentRow(row);
>             HSSFCell cell =
> row.getCell(cellRef1.getCol());
> 
>             form1.evaluateInCell(cell);
> --------------
> the formula in cell C2 is 'A1*B1'. When it executes
> the line
> "form1.evaluateInCell(cell);" it raises
> "ClassCastException". This code is
> working fine with HSSFFormulaEvaluator.evaluate()
> method.
> 
> 2. My second problem is that, how can I evaluate the
> formula, which refer
> some other sheet. e.g. =A1 * Sheet2!B1. I am trying
> to evaluate this formula
> with the HSSFFormulaEvaluator.evaluate() method but
> it does not work. It
> always return me the value of cell A1. (I am using
> the same code as written
> above for this also).
> 
> Plz help me I am in very serious trouble.
> 
> Thanx 
> 
> Nouman
> 
> -- 
> View this message in context:
>
http://www.nabble.com/How-to-evaluate-the-formula-with-multiple-sheet-reference.-tf2642069.html#a7375107
> Sent from the POI - User mailing list archive at
> Nabble.com.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> Mailing List:    
> http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: 
> http://jakarta.apache.org/poi/
> 
> 


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