diff options
-rw-r--r-- | src/documentation/content/xdocs/spreadsheet/how-to.xml | 10 | ||||
-rw-r--r-- | src/examples/src/org/apache/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<InputStream> 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<InputStream> 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); } |