aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java')
-rw-r--r--src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
index 45ab8d8131..4d0b894e01 100644
--- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
+++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
@@ -19,6 +19,7 @@ package org.apache.poi.hssf.eventusermodel;
import java.io.InputStream;
import java.io.IOException;
+import java.util.Set;
import org.apache.poi.hssf.eventusermodel.HSSFUserException;
import org.apache.poi.hssf.record.*;
@@ -56,11 +57,24 @@ public class HSSFEventFactory {
* @param req an Instance of HSSFRequest which has your registered listeners
* @param dir a DirectoryNode containing your workbook
*/
- public void processWorkbookEvents(HSSFRequest req, DirectoryNode dir) throws IOException {
- InputStream in = dir.createDocumentInputStream("Workbook");
-
- processEvents(req, in);
- }
+ public void processWorkbookEvents(HSSFRequest req, DirectoryNode dir) throws IOException {
+ // some old documents have "WORKBOOK" or "BOOK"
+ final String name;
+ Set<String> entryNames = dir.getEntryNames();
+ if (entryNames.contains("Workbook")) {
+ name = "Workbook";
+ } else if (entryNames.contains("WORKBOOK")) {
+ name = "WORKBOOK";
+ } else if (entryNames.contains("BOOK")) {
+ name = "BOOK";
+ } else {
+ name = "Workbook";
+ }
+
+ InputStream in = dir.createDocumentInputStream(name);
+
+ processEvents(req, in);
+ }
/**
* Processes a file into essentially record events.