我正在尝试使用JXL从我的Android设备修改xls文件.如果我很好理解,第一步是复制工作簿.这是我在编写时抛出异常的代码:
java.io.file licencesfile = new java.io.file(licencesService.getPath(mCtx) + "/" + pfilename);java.io.file licencesfiletmp = new java.io.file(licencesService.getPath(mCtx) + "/" + pfilename + ".tmp");is = new fileinputStream(licencesfiletmp);os = new fileOutputStream(licencesfile);Workbook workbookTmp = Workbook.getWorkbook(is);WritableWorkbook workbookFinal = Workbook.createWorkbook(os, workbookTmp);//Todo code will come here when it'll work.workbookFinal.write(); // <= Here is thrown an ExceptionworkbookFinal.close();
我没有找到任何解决方案……任何想法?
非常感谢
堆栈:
java.lang.Arrayindexoutofboundsexception: src.length=166 srcPos=0 dst.length=112 dstPos=0 length=166at java.lang.System.arraycopy(Native Method)at jxl.biff.StringHelper.getBytes(StringHelper.java:127)at jxl.write.biff.WriteAccessRecord.<init>(WriteAccessRecord.java:59)at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:726)at fr.xxx.xxx.tasks.DriveUpdaterasyncTask.updateXls(DriveUpdaterasyncTask.java:170)at fr.xxx.xxx.tasks.DriveUpdaterasyncTask.doInBackground(DriveUpdaterasyncTask.java:71)at fr.xxx.xxx.tasks.DriveUpdaterasyncTask.doInBackground(DriveUpdaterasyncTask.java:1)...etc.
解决方法:
在我的情况下,问题是由复制工作表和设置一些工作簿设置引起的.我使用这些设置作为openWorkbook函数和createWorkbook函数的参数.从createWorkbook函数中删除它们解决了我的问题.
//Load template workbook with settingsWorkbookSettings ws = new WorkbookSettings();ws.setEnCoding("Cp1252");Workbook templateWorkbook = Workbook.getWorkbook(this.context.getAssets().open("template.xls"), ws);//Create new workbook from templateWorkbook without settingsthis.workbook = Workbook.createWorkbook(new file(this.location), templateWorkbook);
总结 以上是内存溢出为你收集整理的Android和JXL:创建WritableWorkbook时的ArrayIndexOutOfBoundException全部内容,希望文章能够帮你解决Android和JXL:创建WritableWorkbook时的ArrayIndexOutOfBoundException所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)