diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 602590675..f07ad2f35 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -41,6 +41,7 @@ --> + 45676 - Handle very long cells in the XSSF EventUserModel example Initial ExtractorFactory support for building TextExtractors for embeded documents Support stripping XSSF header and footer fields (eg page number) out of header and footer text if required Add POIXMLPropertiesTextExtractor, which provides to the OOXML file formats a similar function to HPSF's HPSFPropertiesExtractor diff --git a/src/documentation/content/xdocs/spreadsheet/how-to.xml b/src/documentation/content/xdocs/spreadsheet/how-to.xml index 970482cef..5d70b0834 100644 --- a/src/documentation/content/xdocs/spreadsheet/how-to.xml +++ b/src/documentation/content/xdocs/spreadsheet/how-to.xml @@ -587,10 +587,19 @@ public class ExampleEventUserModel { nextIsString = false; } } + // Clear contents cache + lastContents = ""; } public void endElement(String uri, String localName, String name) throws SAXException { + // Process the last contents as required. + // Do now, as characters() may be called more than once + if(nextIsString) { + int idx = Integer.parseInt(lastContents); + lastContents = sst.getSharedStringAt(idx); + } + // v => contents of a cell // Output after we've seen the string contents if(name.equals("v")) { @@ -600,11 +609,7 @@ public class ExampleEventUserModel { public void characters(char[] ch, int start, int length) throws SAXException { - lastContents = new String(ch, start, length); - if(nextIsString) { - int idx = Integer.parseInt(lastContents); - lastContents = sst.getSharedStringAt(idx); - } + lastContents += new String(ch, start, length); } } diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 9eaab3dad..0adf13d18 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -38,6 +38,7 @@ --> + 45676 - Handle very long cells in the XSSF EventUserModel example Initial ExtractorFactory support for building TextExtractors for embeded documents Support stripping XSSF header and footer fields (eg page number) out of header and footer text if required Add POIXMLPropertiesTextExtractor, which provides to the OOXML file formats a similar function to HPSF's HPSFPropertiesExtractor diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java index d2d78c094..f298ee10f 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java +++ b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java @@ -103,10 +103,19 @@ public class FromHowTo { nextIsString = false; } } + // Clear contents cache + lastContents = ""; } public void endElement(String uri, String localName, String name) throws SAXException { + // Process the last contents as required. + // Do now, as characters() may be called more than once + if(nextIsString) { + int idx = Integer.parseInt(lastContents); + lastContents = sst.getSharedStringAt(idx); + } + // v => contents of a cell // Output after we've seen the string contents if(name.equals("v")) { @@ -116,11 +125,7 @@ public class FromHowTo { public void characters(char[] ch, int start, int length) throws SAXException { - lastContents = new String(ch, start, length); - if(nextIsString) { - int idx = Integer.parseInt(lastContents); - lastContents = sst.getSharedStringAt(idx); - } + lastContents += new String(ch, start, length); } }