Hi Ralf.

Please make a comparison test with POI 2.0. If lists were the only cause
it could run then.

Regards,        Karl-Heinz.


-----Urspr�ngliche Nachricht-----
Von: Ralf Fischer [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 13. August 2004 13:17
An: [EMAIL PROTECTED]
Betreff: ClassCastException on Excel-Load with Image in sheet POI
2.5-final

Hello List,

few weeks ago I started using POI in a report tool to avoid Excel-Save
as CSV.
The Excel File contains 4 Sheets, 1 cover, 1 index and 2 lists important
for 
me. In fact I need just one column. 

Well, on loading this File I get a ClassCastException when I Construct a

HSSFWorkbook, handing the corresponding POIFSFileSystem on the Excel
file:

<exception>
java.lang.ClassCastException
  at java.util.TreeMap.compare(TreeMap.java:1081)
  at java.util.TreeMap.put(TreeMap.java:459)
  at
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.insertCell(V
alueRecordsAggregate.java:65)
  at
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.construct(Va
lueRecordsAggregate.java:130)
  at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:192)
  at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:174)
  at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:132)
  [snip]
</exception>

As an of course not nice workaround I removed this first sheet named
Cover, what
actually not solved the problem, the error didn't occur any more. 

The file in question is available on the internet under this
unfortunately long URL:
http://www3.deutsche-boerse.com/INTERNET/IP/ip_stats.nsf/(KIR+Xetra+Star
s+taeglich)/2F8D6B9F0D183DA1C1256EE40020E5B4/$FILE/XetraStars.xls?OpenEl
ement 
 - yeah, Notes Domino Server is a nice thing ;-)

Here is the code I use for this. Maybe someone can tell me where this
comes from :-)

<code>
private static Set loadExcelSegmentDefinition( File _file , 
                                String _sheetName ) throws Exception {
    log.info( "Loading sheet \"" + _sheetName + "\" from file \"" +
              _file.toString() + "\"..." );
    HashSet result = new HashSet();
    if( _file == null ) return result;
    HSSFWorkbook wb = null;
    try {
        POIFSFileSystem fs = 
        new POIFSFileSystem( new FileInputStream( _file ) );
        wb = new HSSFWorkbook( fs );
    } catch( IOException e ) {
        log.error( "Could not load File \"" + _file.toString() + "\"" );
        return null;
    }
    if( wb != null ) {
        HSSFSheet sheet = wb.getSheet( _sheetName );
        if( sheet == null ) {
            log.error( "No sheet with name \"" + _sheetName + 
                       "\" in file \"" + _file.toString() + 
                       "\"" );
            return null;
        }
        final int row_start = 12;
        final int row_end = sheet.getLastRowNum();
        final short wkn_cell = 2;
        for( int i = row_start ; i <= row_end ; i++ ) {
            HSSFRow row = sheet.getRow( i );
            HSSFCell cell = row.getCell( wkn_cell );
            if( cell != null ) {
                String cellValue = cell.getStringCellValue();
                if( cellValue != null ) {
                    result.add( cellValue );
                }
            }
        }
        }
    if( result.size() > 0 ) {
        log.info( "Loaded " + result.size() +" Figures." );
    } else throw new Exception( "No Figures found in File \"" +
                                _file.toString() + "\", sheet \"" + 
                                _sheetName + "\"!" );
    return result;
}
</code>

For this all I use JDK1.4.1_01 on WindowsNT 4.0 and 
poi-2.4-final-20040302.jar (contrib & scratchpad same version if
important).

Thanks, 
   Ralf



-- 
Ralf Fischer


---------------------------------------------------------------------
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