You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/05/23 10:20:55 UTC
svn commit: r777834 - in /poi/trunk/src: documentation/content/xdocs/
ooxml/java/org/apache/poi/xssf/usermodel/
ooxml/testcases/org/apache/poi/xssf/usermodel/
testcases/org/apache/poi/hssf/data/
Author: yegor
Date: Sat May 23 08:20:55 2009
New Revision: 777834
URL: http://svn.apache.org/viewvc?rev=777834&view=rev
Log:
Fixed XSSFCell to properly read inline strings
Added:
poi/trunk/src/testcases/org/apache/poi/hssf/data/xlsx-jdbc.xlsx (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=777834&r1=777833&r2=777834&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Sat May 23 08:20:55 2009
@@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2009-??-??">
+ <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>
<action dev="POI-DEVELOPERS" type="add">47229 - Fixed ExternalNameRecord to handle DDE links</action>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=777834&r1=777833&r2=777834&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat May 23 08:20:55 2009
@@ -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">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>
<action dev="POI-DEVELOPERS" type="add">47229 - Fixed ExternalNameRecord to handle DDE links</action>
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=777834&r1=777833&r2=777834&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Sat May 23 08:20:55 2009
@@ -242,14 +242,24 @@
rt = new XSSFRichTextString("");
break;
case CELL_TYPE_STRING:
- if (!cell.isSetV()) rt = new XSSFRichTextString("");
- else {
- if (cell.getT() == STCellType.INLINE_STR) {
- return new XSSFRichTextString(cell.getV());
+ if (cell.getT() == STCellType.INLINE_STR) {
+ if(cell.isSetIs()) {
+ //string is expressed directly in the cell definition instead of implementing the shared string table.
+ rt = new XSSFRichTextString(cell.getIs());
+ } else if (cell.isSetV()) {
+ //cached result of a formula
+ rt = new XSSFRichTextString(cell.getV());
} else {
+ rt = new XSSFRichTextString("");
+ }
+ } else {
+ if (cell.isSetV()) {
int idx = Integer.parseInt(cell.getV());
rt = new XSSFRichTextString(sharedStringSource.getEntryAt(idx));
}
+ else {
+ rt = new XSSFRichTextString("");
+ }
}
break;
case CELL_TYPE_FORMULA:
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java?rev=777834&r1=777833&r2=777834&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java Sat May 23 08:20:55 2009
@@ -19,6 +19,7 @@
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
/**
* @author Yegor Kozlov
@@ -50,4 +51,32 @@
cell.setCellFormula(null);
cell.setCellValue("456");
}
+
+ /**
+ * Test that we can read inline strings that are expressed directly in the cell definition
+ * instead of implementing the shared string table.
+ *
+ * Some programs, for example, Microsoft Excel Driver for .xlsx insert inline string
+ * instead of using the shared string table. See bug 47206
+ */
+ public void testInlineString() throws Exception {
+ XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.openSampleWorkbook("xlsx-jdbc.xlsx");
+ XSSFSheet sheet = wb.getSheetAt(0);
+ XSSFRow row = sheet.getRow(1);
+
+ XSSFCell cell_0 = row.getCell(0);
+ assertEquals(STCellType.INT_INLINE_STR, cell_0.getCTCell().getT().intValue());
+ assertTrue(cell_0.getCTCell().isSetIs());
+ assertEquals("A Very large string in column 1 AAAAAAAAAAAAAAAAAAAAA", cell_0.getStringCellValue());
+
+ XSSFCell cell_1 = row.getCell(1);
+ assertEquals(STCellType.INT_INLINE_STR, cell_1.getCTCell().getT().intValue());
+ assertTrue(cell_1.getCTCell().isSetIs());
+ assertEquals("foo", cell_1.getStringCellValue());
+
+ XSSFCell cell_2 = row.getCell(2);
+ assertEquals(STCellType.INT_INLINE_STR, cell_2.getCTCell().getT().intValue());
+ assertTrue(cell_2.getCTCell().isSetIs());
+ assertEquals("bar", row.getCell(2).getStringCellValue());
+ }
}
\ No newline at end of file
Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/xlsx-jdbc.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/xlsx-jdbc.xlsx?rev=777834&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/xlsx-jdbc.xlsx
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/xlsx-jdbc.xlsx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org