DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40296>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40296

           Summary: HSSFCell.setCellFormula throws ClassCastException if
                    cell is created using HSSFRow.createCell(short column,
                    int type)
           Product: POI
           Version: 2.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


The following program throws ClassCastException at line 22. Error message states
"org.apache.poi.hssf.record.BoolErrRecord cannot be cast to
org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate". Seems like there
may be a missing break near line 232 of HSSFCell. Thanks.

import java.io.*;
import org.apache.poi.hssf.usermodel.*;

public class FormulaTest {

  public static void main (String[] args) {

    try {
      FileOutputStream out = new FileOutputStream("FormulaTest.xls");

      HSSFWorkbook workBook = new HSSFWorkbook();
      HSSFSheet workSheet = workBook.createSheet("Sheet1");
      HSSFCell cell = null;
      HSSFRow row = null;

      row = workSheet.createRow(0);
      cell = row.createCell((short)0, HSSFCell.CELL_TYPE_NUMERIC);
      cell.setCellValue(1.0);
      cell = row.createCell((short)1, HSSFCell.CELL_TYPE_NUMERIC);
      cell.setCellValue(2.0);
      cell = row.createCell((short)2, HSSFCell.CELL_TYPE_FORMULA);
      cell.setCellFormula("SUM(A1:B1)");
      workBook.write(out);
      out.close();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }
}

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to