我将通过assets
将我的应用程序assetManager
目录中的Excel文件复制到外部存储中的特定目录。
然后我想通过JExcelAPI
编辑此Excel文件。我使用以下代码执行此操作:
try {
Workbook wb = Workbook.getWorkbook(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Jeeb/save/template.xlsx"));
WritableWorkbook copy = Workbook.createWorkbook(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Jeeb/save/template.xlsx"),wb);
WritableSheet copySheet = copy.getSheet(0);
for(int i = 0 ; i<10 ; i++){
Label label1 = new Label(0,i,"result"+i);
copySheet.addCell(label1);
}
copy.write();
copy.close();
}catch (Exception e){
e.printStackTrace();
}
但是不幸的是,它没有对此Excel文件进行任何更改
logcat
显示此消息:
10-06 12:57:53.009 25234-25234/com.niyazdel.app.jeeb W/System.err: jxl.read.biff.BiffException: Unable to recognize OLE stream
10-06 12:57:53.019 25234-25234/com.niyazdel.app.jeeb W/System.err: at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
10-06 12:57:53.019 25234-25234/com.niyazdel.app.jeeb W/System.err: at jxl.read.biff.File.<init>(File.java:127)
10-06 12:57:53.019 25234-25234/com.niyazdel.app.jeeb W/System.err: at jxl.Workbook.getWorkbook(Workbook.java:268)
10-06 12:57:53.019 25234-25234/com.niyazdel.app.jeeb W/System.err: at jxl.Workbook.getWorkbook(Workbook.java:253)
如何解决这个问题?