Hi All

I am getting a null pointer exception from HSSFFormulaEvaluator.evaluateFormulaCell() when I try to run the following code, similiar to that from the page http://poi.apache.org/hssf/eval.html on my spreadsheet. The formulae are not complicated; if I catch the exception and print out the formulae that are failing I get the list below, although most of the formulae on the sheets are evaluated correctly.

Can anyone shed any light on this problem? Is there something wrong with the format of the cells perhaps?

many thanks in advance
Mike Evans

       for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
           HSSFSheet sheet = wb.getSheetAt(sheetNum);
           HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb);

           for(Iterator<?> rit = sheet.rowIterator(); rit.hasNext();) {
               HSSFRow r = (HSSFRow)rit.next();
               evaluator.setCurrentRow(r);

               for(Iterator<?> cit = r.cellIterator(); cit.hasNext();) {
                   HSSFCell c = (HSSFCell)cit.next();
if(c.getCellType() == HSSFCell.CELL_TYPE_FORMULA) evaluator.evaluateFormulaCell(c);
                   }
               }
           }
       }


java.lang.NullPointerException

        
org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator.xlateRefEval(ValueEvalToNumericXlator.java:165)
        
org.apache.poi.hssf.record.formula.eval.ValueEvalToNumericXlator.attemptXlateToNumeric(ValueEvalToNumericXlator.java:91)
        
org.apache.poi.hssf.record.formula.functions.NumericFunction.singleOperandEvaluate(NumericFunction.java:95)
        
org.apache.poi.hssf.record.formula.functions.MultiOperandNumericFunction.getNumberArray(MultiOperandNumericFunction.java:142)
        
org.apache.poi.hssf.record.formula.functions.MultiOperandNumericFunction.getNumberArray(MultiOperandNumericFunction.java:95)
        org.apache.poi.hssf.record.formula.functions.Sum.evaluate(Sum.java:55)
        
org.apache.poi.hssf.record.formula.eval.FuncVarEval.evaluate(FuncVarEval.java:43)
        
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.internalEvaluate(HSSFFormulaEvaluator.java:395)
        
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCell(HSSFFormulaEvaluator.java:241)
        ...



SUM(C7:C15)
SUM(D7:D15)
D16/C16
SUM(F7:F15)
SUM(G7:G15)
G16/F16
SUM(I7:I15)
SUM(J7:J15)
J16/I16
SUM(L7:L15)
SUM(M7:M15)
M16/L16
SUM(P7:P15)
SUM(Q7:Q15)
Q16/P16
SUM(C7:C15)
SUM(D7:D15)
D16/C16
SUM(F7:F15)
SUM(G7:G15)
G16/F16
SUM(I7:I15)
SUM(J7:J15)
J16/I16
SUM(L7:L15)
SUM(M7:M15)
M16/L16
SUM(O7:O15)
SUM(P7:P15)
P16/O16
SUM(R7:R15)
SUM(S7:S15)
S16/R16
SUM(U7:U15)
SUM(V7:V15)
V16/U16
SUM(Y7:Y15)
SUM(Z7:Z15)
Z16/Y16
SUM(C20:C28)
SUM(D20:D28)
D30/C30
SUM(F20:F28)
SUM(G20:G28)
G30/F30
SUM(I20:I28)
SUM(J20:J28)
J30/I30
SUM(L20:L28)
SUM(M20:M28)
M30/L30
SUM(O20:O28)
SUM(P20:P28)
P30/O30
SUM(R20:R28)
SUM(S20:S28)
S30/R30
SUM(U20:U28)
SUM(V20:V28)
V30/U30
SUM(Y20:Y28)
SUM(Z20:Z28)
Z30/Y30
SUM(C34:C42)
SUM(D34:D42)
D44/C44
SUM(F34:F42)
SUM(G34:G42)
G44/F44
SUM(I34:I42)
SUM(J34:J42)
J44/I44
SUM(L34:L42)
SUM(M34:M42)
M44/L44
SUM(O34:O42)
SUM(P34:P42)
P44/O44
SUM(R34:R42)
SUM(S34:S42)
S44/R44
SUM(U34:U42)
SUM(V34:V42)
V44/U44
SUM(Y34:Y42)
SUM(Z34:Z42)
Z44/Y44
SUM(C7:C9)
SUM(D7:D9)
D10/C10
SUM(F7:F9)
SUM(G7:G9)
G10/F10
SUM(I7:I9)
SUM(J7:J9)
J10/I10
SUM(L7:L9)
SUM(M7:M9)
M10/L10
SUM(O7:O9)
SUM(P7:P9)
P10/O10
SUM(R7:R9)
SUM(S7:S9)
S10/R10
SUM(U7:U9)
SUM(V7:V9)
V10/U10
SUM(Y7:Y9)
SUM(Z7:Z9)
Z10/Y10
--
Mike Evans
Rapid Mobile Ltd.
93 George St. Edinburgh EH2 3ES
Tel: +44 131 243 2502

--
Rapid Mobile Media Limited registered in Scotland No SC263541. Registered for VAT number GB 852 9018 19. Registered office 19A Canning Street, Edinburgh, EH3 8HE.
Contact number: +44(0)131 243 2502
For further information visit our website www.rapid-mobile.com


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

Reply via email to