thx for your answer, but I wanted to adress another issue. Let me explain it
again:
To get the (calculated) value of a cell I do sth like this:

HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(s, workbook);
HSSFCell cell = row.getCell(colnum); //row has the type HSSFRow

At this time the cell object has already a FormulaRecord object containing
all the Ptg objects (field_8_paresed_expr)

HSSFFormulaEvaluator.CellValue actualValue = evaluator.evaluate(cell);

Now the HSSFFormulaEvaluator creates a FormulaParser with the String
representation of the formula (srcCell.getCellFormula()). getCellFormula()
converts the Ptg objects into a String (e.g. "ABS(B7)")
Now FormulaParser.parse() is called and this method parses the String and
creates again the Ptg objects - which were already known before. Afterwards
HSSFFormulaEvaluator uses the Ptg array to evaluate the formula.

Now the question: why is the String transformation necessary at all? Isn't
it possible to use the cell's Ptg objects directly?

Regards,
Guenter


Tahir Akhtar wrote:
> 
> As far as I understand, the Formula Evaluator was added for the 
> use-cases where a POI user wants to calculate the value of a formula in 
> a cell within his Java program. The ability to parse and evaluate a 
> formula is not required to simply write out excel files through POI.
> I haven't seen the internals but I guess the Ptgs you see within the 
> cell object must have been generated by the Formular Parser. I think 
> these Ptgs will not participate in generating actual excel file and are 
> for use with Formula Evaluator only.
> 
> kix wrote:
>> Hi,
>> I was just wondering about the formula evaluation algorithm. Why do you
>> need
>> the FormulaParser at all. The cell already contains the Ptgs within the
>> formula record. But you transform the Ptgs into a string representation
>> and
>> then parse the string to reconstruct the Ptgs. 
>>
>> Maybe I miss something, but I really don't see the point.
>>
>> Thx,
>> Günter
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/HSSF-FormulaParser---HSSFFormulaEvaluator-question-tf4321995.html#a12343326
Sent from the POI - User mailing list archive at Nabble.com.


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

Reply via email to