Bug 44861 - ClassCastException in evaluateFormulaCell
Summary: ClassCastException in evaluateFormulaCell
Status: RESOLVED DUPLICATE of bug 44606
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Windows Vista
: P1 critical with 4 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-04-23 09:11 UTC by Emmanuel F
Modified: 2008-04-28 12:00 UTC (History)
0 users

Testcase (60.00 KB, application/octet-stream)
2008-04-28 10:43 UTC, Emmanuel F

Note You need to log in before you can comment on or make changes to this bug.
Description Emmanuel F 2008-04-23 09:11:12 UTC
Tested with poi-3.0.2-FINAL

java.lang.ClassCastException: org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate cannot be cast to org.apache.poi.hssf.record.LabelSSTRecord
        at org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(HSSFCell.java:625)
        at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCell(HSSFFormulaEvaluator.java:253)

My code :

private final void updateAllFormulas(final HSSFWorkbook parWorkbook) {
    final int locNumberOfSheets = parWorkbook.getNumberOfSheets();
    for (int locSheetNum = 0; locSheetNum < locNumberOfSheets; locSheetNum++) {
      final HSSFSheet locSheet = parWorkbook.getSheetAt(locSheetNum);
      final HSSFFormulaEvaluator locEvaluator = new HSSFFormulaEvaluator(locSheet, parWorkbook);

      for (final Iterator locSheetIter = locSheet.rowIterator(); locSheetIter.hasNext();) {
        final HSSFRow locRow = (HSSFRow) locSheetIter.next();

        for (final Iterator locCellIter = locRow.cellIterator(); locCellIter.hasNext();) {
          final HSSFCell locCell = (HSSFCell) locCellIter.next();
          if (locCell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
Comment 1 Nick Burch 2008-04-27 11:00:29 UTC
Please upload the problem excel file, so we can take a look and see what POI is doing wrong (the stacktrace shows something happening that ought not to)
Comment 2 Emmanuel F 2008-04-28 10:43:02 UTC
Created attachment 21870 [details]
Comment 3 Emmanuel F 2008-04-28 10:44:43 UTC
The problem excel file is in attachments.
Comment 4 Nick Burch 2008-04-28 10:53:16 UTC
Just tried on svn trunk, and works just fine, no exception. Test added to svn verifies this

Please retry with 3.1 beta 1 (should be on mirrors shortly) or a svn nightly build. 
Comment 5 Josh Micich 2008-04-28 12:00:17 UTC
The stack trace seems to be the same as that from bug 44606

*** This bug has been marked as a duplicate of bug 44606 ***