poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 16410] New: - Exception when using HSSFCell.setCellType to change cell type of existing cell
Date Fri, 24 Jan 2003 22:15:03 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16410>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16410

Exception when using HSSFCell.setCellType to change cell type of existing cell

           Summary: Exception when using HSSFCell.setCellType to change cell
                    type of existing cell
           Product: POI
           Version: 1.5.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: jason@compositesw.com


POI version 1.5.1
excel 2002 10.2614.2625

not sure what the behavior of setCellType should be, but this strikes me as a 
bug. my assumption is that a cell, regardless of it's content, can have its 
type changed without directly modifying the content first.


using the example program, ReadWriteWorkbook, with a blank excel spreadsheet 
called workbook.xls. when the example program tries to set the cell type to 
CELL_TYPE_STRING the following exception is thrown:

Exception in thread "main" java.lang.NumberFormatException: You cannot get a str
ing value from a numeric cell
        at org.apache.poi.hssf.usermodel.HSSFCell.getStringCellValue(HSSFCell.ja
va:757)
        at org.apache.poi.hssf.usermodel.HSSFCell.setCellType(HSSFCell.java:495)

        at org.apache.poi.hssf.usermodel.HSSFCell.setCellType(HSSFCell.java:410)

        at org.apache.poi.hssf.usermodel.examples.ReadWriteWorkbook.main(ReadWri
teWorkbook.java:86)

in order to find out more i modified the example program and found the 
following:
the cell defaults to CELL_TYPE_NUMERIC.
if the cell VALUE is set as a numeric with a value of 0, then the value is set 
to a null string, then the cell type is changed to a string, it works fine.

guess at what is happening: cell, upon change of type, accesses the data in the 
cell as the type it will become. the cell type has not changed yet, so there is 
an exception where the data, still as old type cell, is trying to be accessed 
as new type cell.

the same behavior occurs when trying to convert to numeric cell to string cell.

Mime
View raw message