Bug 40460 - java.lang.ClassCastException: org.apache.poi.hssf.record.LabelRecord
Summary: java.lang.ClassCastException: org.apache.poi.hssf.record.LabelRecord
Status: RESOLVED DUPLICATE of bug 19053
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: Other Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-11 08:37 UTC by Hepzibah Rajulah
Modified: 2008-05-05 20:18 UTC (History)
0 users



Attachments
this is the template i want to use (101.50 KB, application/octet-stream)
2006-09-11 08:42 UTC, Hepzibah Rajulah
Details
Proposed fix to kludge for LabelRecord data type (36.27 KB, patch)
2007-03-21 08:03 UTC, Glenn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hepzibah Rajulah 2006-09-11 08:37:19 UTC
java.lang.ClassCastException: org.apache.poi.hssf.record.LabelRecord
	java.util.TreeMap.compare(TreeMap.java:1093)
	java.util.TreeMap.put(TreeMap.java:465)
	org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.insertCell
(ValueRecordsAggregate.java:65)
	org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.construct
(ValueRecordsAggregate.java:130)
	org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:210)
	org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:172)
	org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:130)
	org.springframework.web.servlet.view.document.AbstractExcelView.getTemp
lateSource(AbstractExcelView.java:165)
	org.springframework.web.servlet.view.document.AbstractExcelView.renderM
ergedOutputModel(AbstractExcelView.java:132)
	org.springframework.web.servlet.view.AbstractView.render
(AbstractView.java:250)

While trying to use the template already given by Client which has Gaphs an 
dthe base data
Comment 1 Hepzibah Rajulah 2006-09-11 08:42:29 UTC
Created attachment 18847 [details]
this is the template i want to use
Comment 2 Glenn 2007-03-21 08:03:44 UTC
Created attachment 19767 [details]
Proposed fix to kludge for LabelRecord data type

The current kludge for converting out-dated LabelRecords to LabelSSTRecords
generated ClassCastExceptions when I tried to read a spreadsheet created by MS
Works, supposedly saved in Excel 97/2000 format.

The problem appears to be that the conversion method :
    sheet.convertLabelRecords(workbook);
is called too late in the sequence.  By the time it is called, the records have
already been processed, and it is during that processing that the exception
fails.	The specific issue is that LabelRecord does not implement Comparator
interface, but there is a secondary problem that the LabelRecords are inserted
into a second data structure (ValueRecordsAggregate	 cells) during that
process and those entries are not converted to LabelSSTRecords during the
conversion.

I believe the better way to handle this is to do the conversion in
usermodel.HSSFWorkbook.java prior to creating the Sheet objects.  This appears
to work for me.  The code changes in the attached file are located between line
numbers 170 and 210.  They do the conversion on the records structure and
comment out the call to convertLabelRecords in Sheet.  That method might be
eliminated if this patch is applied.
Comment 3 Josh Micich 2008-05-05 20:18:32 UTC
Retested OK in 3.1-beta1.

Probably fixed in svn r353774 (for bug 19053)


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