Fixed XSSFCell to avoid generating xsi:nil entries in shared string table
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@780228 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bc39bacebd
commit
15a46deae0
@ -34,6 +34,7 @@
|
||||
<!-- Don't forget to update changes.xml too! -->
|
||||
<changes>
|
||||
<release version="3.5-beta6" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">47278 - Fixed XSSFCell to avoid generating xsi:nil entries in shared string table</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">47206 - Fixed XSSFCell to properly read inline strings</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">47250 - Fixed FontRecord to expect unicode flags even when name length is zero</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">47198 - Fixed formula evaluator comparison of -0.0 and 0.0</action>
|
||||
|
@ -293,7 +293,7 @@ public final class XSSFCell implements Cell {
|
||||
* If value is null then we will change the cell to a Blank cell.
|
||||
*/
|
||||
public void setCellValue(RichTextString str) {
|
||||
if(str == null){
|
||||
if(str == null || str.getString() == null){
|
||||
setBlank();
|
||||
return;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.XSSFITestDataProvider;
|
||||
import org.apache.poi.xssf.model.SharedStringsTable;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
|
||||
|
||||
/**
|
||||
@ -79,4 +80,30 @@ public final class TestXSSFCell extends BaseTestCell {
|
||||
assertTrue(cell_2.getCTCell().isSetIs());
|
||||
assertEquals("bar", row.getCell(2).getStringCellValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug 47278 - xsi:nil attribute for <t> tag caused Excel 2007 to fail to open workbook
|
||||
*/
|
||||
public void test47278() throws Exception {
|
||||
XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.createWorkbook();
|
||||
XSSFSheet sheet = wb.createSheet();
|
||||
XSSFRow row = sheet.createRow(0);
|
||||
SharedStringsTable sst = wb.getSharedStringSource();
|
||||
assertEquals(0, sst.getCount());
|
||||
|
||||
//case 1. cell.setCellValue(new XSSFRichTextString((String)null));
|
||||
XSSFCell cell_0 = row.createCell(0);
|
||||
XSSFRichTextString str = new XSSFRichTextString((String)null);
|
||||
assertNull(str.getString());
|
||||
cell_0.setCellValue(str);
|
||||
assertEquals(0, sst.getCount());
|
||||
assertEquals(XSSFCell.CELL_TYPE_BLANK, cell_0.getCellType());
|
||||
|
||||
//case 2. cell.setCellValue((String)null);
|
||||
XSSFCell cell_1 = row.createCell(1);
|
||||
cell_1.setCellValue((String)null);
|
||||
assertEquals(0, sst.getCount());
|
||||
assertEquals(XSSFCell.CELL_TYPE_BLANK, cell_1.getCellType());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user