]> source.dussan.org Git - poi.git/commitdiff
Fix an off-by-one in the xssf eventmodel example and docs
authorNick Burch <nick@apache.org>
Fri, 4 Apr 2008 12:24:38 +0000 (12:24 +0000)
committerNick Burch <nick@apache.org>
Fri, 4 Apr 2008 12:24:38 +0000 (12:24 +0000)
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
src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java

index 4d13aeee5e646c7570726378a272a74d85ea38fe..970482cef965d9e51f3012b2c9e896c5e1692255 100644 (file)
@@ -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);
                        }
index 794fdee0e2ded62a982f3e9f9b79c8978c5b5f92..d2d78c0943cf7632751d767ef39f97fe6c336ad4 100644 (file)
@@ -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);
                        }