开发者

JXL Won't Allow Excel 2007 Extensions

I am using JXL to write an Excel report. Everything works fine if I use the .XLS extension. However, when I use the .XLSM extension, 开发者_如何学JAVAthe report fails to load when I try to open it. I get the message "Excel cannot open the file 'TestExcel.xlsm' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file". Below is a simplified version of what I am doing. As mentioned, it works if you change the filePath to use .XLS instead.

String filePath = "C:\\Users\\Rachel\\Desktop\\TestExcel.xlsm";
File excelFile = new File(filePath);

WritableWorkbook book = Workbook.createWorkbook(excelFile);
WritableSheet sheet = book.createSheet("Test Sheet", 0);

sheet.addCell(new Label(0, 0, "Testing..."));

book.write();
book.close();

I am using Excel 2007 to open the file. If I create a new workbook in Excel, save it as xlsm, close it, and then open it, Excel opens it correctly. Does anyone know how to make the JXL file open correctly? I cannot switch to Apache POI or anything, I have to use JXL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜