我有错误:
workbook.write();
当我尝试调试时,我看到按摩:“找不到源。”
它是如何修复的?
private void exportExcel() throws IOException, WriteException{
File file = new File(Environment.getExternalStorageDirectory() + "/backup.xls");
WritableWorkbook workbook = Workbook.createWorkbook(file);
workbook.createSheet("worksheet", 0);
workbook.write();
workbook.close();
}
提前致谢
WTF 我上面的代码开始工作了!!!
当我开始时,我使用默认的 jexcelapi。之后我开始使用替代 jexcelapi,但它也不起作用。
当我尝试对您的代码进行少量更改时-它可以工作!你的代码:
private void exportExcel() throws WriteException, IOException{
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File(sdCard + "/myFolder");
//make them in case they're not there
dir.mkdirs();
//create a standard java.io.File object for the Workbook to use
File wbfile = new File(dir, "backup.xls");
WritableWorkbook workbook = null;
try{
workbook = Workbook.createWorkbook(wbfile);
workbook.createSheet("worksheet", 0);
workbook.write();
workbook.close();
} catch (IOException ex) {
Log.e("Workbook Test", "Could not create " + wbfile.getPath(), ex);
}
}
但是当我尝试上面的代码时,它也可以工作。
也许 Eclipse 不会立即使用库更新?
非常感谢你!
PS对不起我的英语不好。