Thanks. It's working now.   I think my problem was that I wasn't calling the 
Evaluator's setCurrentRow method:

   HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator (sheet, wb);

   int rows = sheet.getLastRowNum();
   for (int r = 0; r < rows; r++)
   {
      HSSFRow row = sheet.getRow (r);
      evaluator.setCurrentRow (row);

      short first = row.getFirstCellNum();
      short last = row.getLastCellNum();
      for (short c = first; c < last; c++)
      {
         HSSFCell cell = row.getCell (c);
         if (cell != null &&
             cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA)
         {
            String formula = cell.getCellFormula();
            if (formula != null)
               evaluator.evaluateInCell (cell);
         }
      }
   }

-----Original Message-----
From: Nick Burch [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2008 10:58 AM
To: POI Users List
Subject: Re: HSSF formula cells not calculating

On Tue, 18 Mar 2008, J Keller wrote:
> Using poi-3.0-rc4, I'm reading an Excel spreadsheet (which works fine);
> changing some values (which works fine), and saving it out as a new
> version (which also works fine).
>
> But, when I open the spreadsheet, all of my formula cells are not
> calculated (nor can I tell the spreadsheet to recalc using F9 for
> example).

That's expected. You either need to force excel to re-calculate on load,
or do the recalculation yourself:
        http://poi.apache.org/hssf/eval.html
By default, excel will just used the cached formula values

Nick

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


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

Reply via email to