Running into warnings and errors using JSpreadshee

2019-08-30 02:42发布

问题:

I'm using JSpreadSheet to read an xlsx file from the SDCard and try as I might I cannot get the app to work. I've tried the same code in Java and it work flawlessly, outputting the cells to system.out but it doesn't seem to be working in Android. Please help !

Here's my function:

public void readAndDisplay(){





                try
                {
                    Workbook book = new Workbook("/sdcard/new.xlsx");

                    for (Sheet sheet : book.getSheets())
                    {
                        if (sheet instanceof Worksheet)
                        {
                            Worksheet worksheet = (Worksheet)sheet;
                            List<Cell> cells = worksheet.getCells();

                            for (int i = 0; i < cells.size(); i++)
                            {
                                System.out.println(cells.get(i).getReference() + " = " + cells.get(i).getValue());
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    System.out.println(e.getMessage());
                    e.printStackTrace();
                }





    }

I know I should be using Environment to get to the SDCard but that's not the issue right now. The warnings I get are these, the app crashes and doesn't run at all on the emulator.

08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to resolve interface method 21548: Ljavax/xml/stream/XMLStreamReader;.hasNext ()Z
08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to resolve interface method 21548: Ljavax/xml/stream/XMLStreamReader;.hasNext ()Z
08-17 19:08:17.420: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21544: Ljavax/xml/stream/XMLStreamReader;.getAttributeValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21548: Ljavax/xml/stream/XMLStreamReader;.hasNext ()Z
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamReader;)
08-17 19:08:17.430: W/dalvikvm(5240): VFY: unable to resolve interface method 21548: Ljavax/xml/stream/XMLStreamReader;.hasNext ()Z
08-17 19:09:14.670: W/System.err(5297):     at com.independentsoft.office.spreadsheet.Workbook.<init>(SourceFile:64)
08-17 19:09:14.670: W/System.err(5297):     at com.example.gss4internal.MainActivity.readAndDisplay(MainActivity.java:32)
08-17 19:09:14.670: W/System.err(5297):     at com.example.gss4internal.MainActivity.onCreate(MainActivity.java:21)
08-17 19:09:14.670: W/System.err(5297):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-17 19:09:14.670: W/System.err(5297):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-17 19:09:14.670: W/System.err(5297):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-17 19:09:14.670: W/System.err(5297):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-17 19:09:14.670: W/System.err(5297):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-17 19:09:14.670: W/System.err(5297):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-17 19:09:14.670: W/System.err(5297):     at android.os.Looper.loop(Looper.java:130)
08-17 19:09:14.670: W/System.err(5297):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-17 19:09:14.670: W/System.err(5297):     at java.lang.reflect.Method.invokeNative(Native Method)
08-17 19:09:14.670: W/System.err(5297):     at java.lang.reflect.Method.invoke(Method.java:507)
08-17 19:09:14.670: W/System.err(5297):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
08-17 19:09:14.670: W/System.err(5297):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
08-17 19:09:14.670: W/System.err(5297):     at dalvik.system.NativeStart.main(Native Method)

回答1:

They have separate jar file for Android. Be sure that you use jar file for Android, not for Java SDK.