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

           Summary: [PATCH]NullPointerException in
                    HSSFWorkbook.convertLabelRecords
           Product: POI
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=23147)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23147)
Patch for NPX in HSSFWorkbook.convertLabelRecords()

When reading an Excel Sheet with an embedded Excel Diagram a Nullpointer
Exception occurs at HSSFWorkbook.convertLabelRecords:

Caused by: java.lang.NullPointerException
        at
org.apache.poi.hssf.record.UnicodeString.setString(UnicodeString.java:343)
        at
org.apache.poi.hssf.record.UnicodeString.<init>(UnicodeString.java:104)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.convertLabelRecords(HSSFWorkbook.java:303)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:215)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:259)
        at
com.framesoft.ffr.dms.lucene.documentHandler.ExcelPoiHSSFHandler.getDocumentContent(ExcelPoiHSSFHandler.java:25)
        ... 1 more

I fixed this issue for our project where we extract the text from multiple
Excel Documents by changing this Line:

workbook.addSSTString(new UnicodeString(oldrec.getValue()));

with this Line:

workbook.addSSTString((oldrec.getValue() == null ? null : new
UnicodeString(oldrec.getValue())));

I don't know if this is a valid solution for this issue but for us it fixed the
problem. 

Maybe there is a problem with some of the ExcelSheets we are trying to read
that have a LabelRecord with a Null value. The Nullpointer did not occur if one
of the embedded ExcelDiagrams was removed. The Diagram is referencing a Table
with an empty row, so maybe that is the reason for the problem. 

I attached an example for this diagram that will result in an NPX.


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