From b6a6618be792316957320ebc2e5475282b84cf3f Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 4 Apr 2008 12:24:38 +0000 Subject: [PATCH] Fix an off-by-one in the xssf eventmodel example and docs git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@644692 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/spreadsheet/how-to.xml | 10 +++++++++- .../poi/xssf/eventusermodel/examples/FromHowTo.java | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/documentation/content/xdocs/spreadsheet/how-to.xml b/src/documentation/content/xdocs/spreadsheet/how-to.xml index 4d13aeee5e..970482cef9 100644 --- a/src/documentation/content/xdocs/spreadsheet/how-to.xml +++ b/src/documentation/content/xdocs/spreadsheet/how-to.xml @@ -542,10 +542,12 @@ public class ExampleEventUserModel { Iterator sheets = r.getSheetsData(); while(sheets.hasNext()) { + System.out.println("Processing new sheet:\n"); InputStream sheet = sheets.next(); InputSource sheetSource = new InputSource(sheet); parser.parse(sheetSource); sheet.close(); + System.out.println(""); } } @@ -578,13 +580,19 @@ public class ExampleEventUserModel { // Print the cell reference System.out.print(attributes.getValue("r") + " - "); // Figure out if the value is an index in the SST - if(attributes.getValue("t").equals("s")) { + String cellType = attributes.getValue("t"); + if(cellType != null && cellType.equals("s")) { nextIsString = true; } else { nextIsString = false; } } + } + + public void endElement(String uri, String localName, String name) + throws SAXException { // v => contents of a cell + // Output after we've seen the string contents if(name.equals("v")) { System.out.println(lastContents); } 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 794fdee0e2..d2d78c0943 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 @@ -58,10 +58,12 @@ public class FromHowTo { Iterator sheets = r.getSheetsData(); while(sheets.hasNext()) { + System.out.println("Processing new sheet:\n"); InputStream sheet = sheets.next(); InputSource sheetSource = new InputSource(sheet); parser.parse(sheetSource); sheet.close(); + System.out.println(""); } } @@ -94,13 +96,19 @@ public class FromHowTo { // Print the cell reference System.out.print(attributes.getValue("r") + " - "); // Figure out if the value is an index in the SST - if(attributes.getValue("t").equals("s")) { + String cellType = attributes.getValue("t"); + if(cellType != null && cellType.equals("s")) { nextIsString = true; } else { nextIsString = false; } } + } + + public void endElement(String uri, String localName, String name) + throws SAXException { // v => contents of a cell + // Output after we've seen the string contents if(name.equals("v")) { System.out.println(lastContents); } -- 2.39.5