https://issues.apache.org/bugzilla/show_bug.cgi?id=44606

           Summary: ClassCastException
           Product: POI
           Version: 3.0
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


Created an attachment (id=21666)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21666)
The java file to compile, and the xls file. Run the java file using the xls
file as argument to get the error.

Hello,

POI Version: poi-3.0.2-FINAL, jdk1.6.0_05
Run by: java -classpath
poi-scratchpad-3.0.2-FINAL-20080204.jar;poi-3.0.2-FINAL-20080204.jar;. 
MyExample
Error: Exception in thread "main" 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)
        at MyExample.main(MyExample.java:42)

The problem is that I am using in a cell a string and a formula like: '"Sold by
Company, TOT = "&SUM(D52:D55)'

This type of formula is stopping the program with the error.

Program:

        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) {
                        System.out.println(c);
                        evaluator.evaluateFormulaCell(c); // <--- LINE 42 ----
                    }
                }
            }
        }


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

Reply via email to