poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikhilgonsalves <nikhil.gonsal...@gmail.com>
Subject Interesting Error - "Unexpected operation ptg class (org.apache.poi.hssf.record.formula.IntersectionPtg)"
Date Mon, 12 Oct 2009 15:47:32 GMT

Hi all,

We are reading an Excel document in which the formulae are dynamicall
executed using the POI API. Almost all the formulae are executed
successfully but for a few. THese ones use intersection between two ranges


For example, there are two ranges - previous (which is a vertical range --
A:A) and test ( which is a horizontal range -- A1:C1). These two intersect
at cell A1. The formula is cell C1 is "=A2*previous test". This works fine
in Excel but when the same file is read and evaluated in POI, the error we
get is below:

java.lang.RuntimeException: Unexpected operation ptg class
(org.apache.poi.hssf.record.formula.IntersectionPtg)
        at
org.apache.poi.ss.formula.OperationEvaluatorFactory.create(OperationEvaluatorFactory.java:170)
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:295)
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:214)
        at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:178)
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCellValue(HSSFFormulaEvaluator.java:297)
        at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluate(HSSFFormulaEvaluator.java:159)

The following code is used to evaluate a cells numeric value:

HSSFCell hcell = row.getCell(colId);
            if (hcell != null){
          	
            	FormulaEvaluator evaluator =
wb.getCreationHelper().createFormulaEvaluator();
            	
            	CellValue cell = evaluator.evaluate(hcell);
             return cell.getNumberValue();

CAn anyone help us? Thanks a lot!

Nikhil

-- 
View this message in context: http://www.nabble.com/Interesting-Error---%22Unexpected-operation-ptg-class-%28org.apache.poi.hssf.record.formula.IntersectionPtg%29%22-tp25858056p25858056.html
Sent from the POI - User mailing list archive at Nabble.com.


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


Mime
View raw message