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
This commit is contained in:
Nick Burch 2008-04-04 12:24:38 +00:00
parent c44e3a4b4a
commit 95756c5472
2 changed files with 18 additions and 2 deletions

View 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);
}

View 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);
}