Bug 47278

Summary: xsi:nil attribute for <t> tag caused Excel 2007 to fail to open workbook
Product: POI Reporter: Eduard Dudar <eduard.dudar>
Component: XSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   

Description Eduard Dudar 2009-05-28 03:18:40 UTC
At some conditions POI XSSF generates the following shared string element:
<si><t xsi:nil="true"/></si>

Opening such workbook caused an error with text like that:
"Removed Part: /xl/sharedStrings.xml part with XML error.  (Strings) Load error. Line 2, column 174962.
Removed Records: Cell information from /xl/worksheets/sheet1.xml part"

Column number of course will be different in other examples but points to element above.

Actually such attribute is valid for XML and says that tag's value is empty but Excel doesn't understand this. Huh.
Comment 1 Yegor Kozlov 2009-05-28 06:45:00 UTC
Can you post sample code that generates xsi:nil entries in sharedStrings.xml? It would be helpful to diagnose the problem.

Comment 2 Eduard Dudar 2009-05-28 07:20:48 UTC
Original source code where I have this is quite tightly coupled within huge application and will not give any value without own environment. I'm going to simplify this case as much as it will be possible and will back here.
Comment 3 Yegor Kozlov 2009-05-30 03:43:48 UTC
Fixed in r780228.

Passing null to the XSSFRichTextString constructor resulted in xsi:nil for the <t> tag. A minimal code to reproduce the behavior is as follows:

  XSSFCell cell = sheet.createRow(0).createCell(0);
  cell.setCellValue(new XSSFRichTextString((String)null));

I fixed setCellValue to blank cell ( erase all the data previously associated with this cell) if the argument string is null.