我正在使用 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)