aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2018-10-17 14:24:59 +0000
committerNick Burch <nick@apache.org>2018-10-17 14:24:59 +0000
commitf490cd7c5de69dd057ae2a7e5067baaf503bb792 (patch)
tree0c83eaa6910ac7f17906adf904a410b11f103e0d /src/java/org/apache
parente95fc069293db1fd4988053c6cc078af1287612c (diff)
downloadpoi-f490cd7c5de69dd057ae2a7e5067baaf503bb792.tar.gz
poi-f490cd7c5de69dd057ae2a7e5067baaf503bb792.zip
#62831 Fix WorkbookFactory.create with a subclass of File, eg from JFileChooser
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1844116 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
index 50833aa6c2..aae8c043ce 100644
--- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
+++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
@@ -296,6 +296,11 @@ public class WorkbookFactory {
return createWorkbook("org.apache.poi.xssf.usermodel.XSSFWorkbookFactory", args);
}
+ /**
+ * Does the actual call to HSSF or XSSF to do the creation.
+ * Uses reflection, so that this class can be in the Core non-OOXML
+ * POI jar without errors / broken references to the OOXML / XSSF code.
+ */
private static Workbook createWorkbook(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
try {
Class<?> clazz = WorkbookFactory.class.getClassLoader().loadClass(factoryClass);
@@ -307,6 +312,8 @@ public class WorkbookFactory {
c = boolean.class;
} else if (InputStream.class.isAssignableFrom(c)) {
c = InputStream.class;
+ } else if (File.class.isAssignableFrom(c)) {
+ c = File.class;
}
argsClz[i++] = c;
}