diff options
author | Nick Burch <nick@apache.org> | 2018-10-17 14:24:59 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2018-10-17 14:24:59 +0000 |
commit | f490cd7c5de69dd057ae2a7e5067baaf503bb792 (patch) | |
tree | 0c83eaa6910ac7f17906adf904a410b11f103e0d /src/java/org/apache | |
parent | e95fc069293db1fd4988053c6cc078af1287612c (diff) | |
download | poi-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.java | 7 |
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; } |