https://bz.apache.org/bugzilla/show_bug.cgi?id=63303

--- Comment #6 from [email protected] ---
According to the source
https://svn.apache.org/repos/asf/poi/trunk/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java

In method createWorkbook(String, Object[]) it will try to look for
org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(java.io.File,
Boolean). When the method is not found it's not found exception is thrown
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getMethod-java.lang.String-java.lang.Class...-


    private static Workbook createXSSFWorkbook(Object... args) throws
IOException, EncryptedDocumentException {
        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);
            Class<?>[] argsClz = new Class<?>[args.length];
            int i=0;
            for (Object o : args) {
                Class<?> c = o.getClass();
                if (Boolean.class.isAssignableFrom(c)) {
                    c = boolean.class;
                } else if (InputStream.class.isAssignableFrom(c)) {
                    c = InputStream.class;
                } else if (File.class.isAssignableFrom(c)) {
                    c = File.class;
                }
                argsClz[i++] = c;
            }
            Method m = clazz.getMethod("createWorkbook", argsClz);
            return (Workbook)m.invoke(null, args);

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to