Не получается создать чтение файлов .xls и .xlsx через Apache Poi

Проблема такая - не получается через Apache Poi сделать чтение файла по прямой ссылке к файлу, дальше прикладываю код для чтения файлов .xls(x) и лог с ошибкой. Вообще пробовал разный код, но всегда ругается конкретно на строчку, где есть например XSSFWorkbook или HSSFWorkbook.
Код чтения файлов:

public void readExcelData(String ExcelFilePath) {
    // HSSFWorkbook is for .xls
    // XSSFWorkbook is for .xlsx
    String[] path = ExcelFilePath.split(":");

    Workbook workbook = null;

    if (ExcelFilePath.endsWith(".xls")) {
        try {
            InputStream inputStream = new FileInputStream(new File(path[1]));
            workbook = new HSSFWorkbook(inputStream);
        } catch (FileNotFoundException e) {
            Log.i("debinf cliinf", "readExcelData: FileNotFoundException " + e.getMessage());
        } catch (IOException e) {
            Log.i("debinf cliinf", "readExcelData: Error reading InputStream " + e.getMessage());
        }

    } else if (ExcelFilePath.endsWith(".xlsx")) {
        try {
            //изменил в патче 1 на 0
            InputStream inputStream = new FileInputStream(new File(path[0]));
            workbook = new XSSFWorkbook(inputStream);
        } catch (FileNotFoundException e) {
            Log.i("debinf cliinf", "readExcelData: FileNotFoundException " + e.getMessage());
        } catch (IOException e) {
            Log.i("debinf cliinf", "readExcelData: Error reading InputStream " + e.getMessage());
        }
    }

    Log.i("debinf cliinf", "uri is " + ExcelFilePath.endsWith(".xls"));


    //Sheet sheet = workbook.getSheetAt(0);
    //Log.i("debinf cliinfo", "sheet is " + sheet);
    //if (sheet == null) {
    //}
}

Лог с ошибкой:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.findsku, PID: 20097
java.lang.IllegalStateException: Could not execute method for android:onClick
    at android.view.View$DeclaredOnClickListener.onClick(View.java:5634)
    at android.view.View.performClick(View.java:6597)
    at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at android.view.View$DeclaredOnClickListener.onClick(View.java:5629)
    at android.view.View.performClick(View.java:6597) 
    at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992) 
    at android.view.View.performClickInternal(View.java:6574) 
    at android.view.View.access$3100(View.java:778) 
    at android.view.View$PerformClick.run(View.java:25885) 
    at android.os.Handler.handleCallback(Handler.java:873) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
 Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLStreamReader;
    at org.apache.xmlbeans.XmlBeans.buildStreamToNodeMethod(XmlBeans.java:251)
    at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:138)
    at org.apache.xmlbeans.XmlBeans.typeLoaderForClassLoader(XmlBeans.java:719)
    at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.getTypeLoader(Unknown Source:23)
    at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source:0)
    at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
    at org.apache.poi.xssf.usermodel.-$$Lambda$aHAEGSKKrWHqrDl7wEbry96rXeU.init(Unknown Source:2)
    at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61)
    at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:684)
    at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:180)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:288)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:309)
    at com.example.findsku.MainActivity.readExcelData(MainActivity.java:93)
    at com.example.findsku.MainActivity.appointButtonClick(MainActivity.java:65)
    at java.lang.reflect.Method.invoke(Native Method) 
    at android.view.View$DeclaredOnClickListener.onClick(View.java:5629) 
    at android.view.View.performClick(View.java:6597) 
    at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992) 
    at android.view.View.performClickInternal(View.java:6574) 
    at android.view.View.access$3100(View.java:778) 
    at android.view.View$PerformClick.run(View.java:25885) 
    at android.os.Handler.handleCallback(Handler.java:873) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
 Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLStreamReader" on path: DexPathList[[zip file "/data/app/com.example.findsku-GTzyPGiD3KBgE6Vesm5yAw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.findsku-GTzyPGiD3KBgE6Vesm5yAw==/lib/x86, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at org.apache.xmlbeans.XmlBeans.buildStreamToNodeMethod(XmlBeans.java:251) 
    at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:138) 
    at org.apache.xmlbeans.XmlBeans.typeLoaderForClassLoader(XmlBeans.java:719) 
    at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.getTypeLoader(Unknown Source:23) 
    at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source:0) 
    at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86) 
    at org.apache.poi.xssf.usermodel.-$$Lambda$aHAEGSKKrWHqrDl7wEbry96rXeU.init(Unknown Source:2) 
    at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61) 
    at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:684) 
    at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:180) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:288) 
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:309) 
    at com.example.findsku.MainActivity.readExcelData(MainActivity.java:93) 
    at com.example.findsku.MainActivity.appointButtonClick(MainActivity.java:65) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at android.view.View$DeclaredOnClickListener.onClick(View.java:5629) 
    at android.view.View.performClick(View.java:6597) 
    at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:992) 
    at android.view.View.performClickInternal(View.java:6574) 
    at android.view.View.access$3100(View.java:778) 
    at android.view.View$PerformClick.run(View.java:25885) 
    at android.os.Handler.handleCallback(Handler.java:873) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

Либо картинкой.


Ответы (0 шт):