使用JSpreadsheet运行警告和错误

时间:2013-08-17 14:16:13

标签: java android excel apache-poi adt

我正在使用JSpreadSheet从SDCard读取xlsx文件,并尝试我可能无法让应用程序工作。我在Java中尝试了相同的代码并且它完美地工作,将单元格输出到system.out但它似乎在Android中不起作用。请帮忙!

这是我的功能:

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();
                }





    }

我知道我应该使用Environment来访问SDCard,但现在不是问题。我得到的警告是这些,应用程序崩溃,并且在模拟器上根本不运行。

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 个答案:

答案 0 :(得分:0)

他们有Android的独立jar文件。请确保您使用的是适用于Android的jar文件,而不是Java SDK。