我想要一个读取宏启用(.xlsm)文件的解决方案,并将内容写在excel文件上。
我已尝试过以下内容。
String fileName = "sample.xlsm";
String path = "../documents/macro_CleanUp.xlsm";
OPCPackage pkg = OPCPackage.open(new File(path));
XSSFWorkbook wb_template = new XSSFWorkbook(pkg);
SXSSFWorkbook workbook = new SXSSFWorkbook(wb_template);
workbook.setCompressTempFiles(true);
SXSSFSheet sheet = (SXSSFSheet) workbook.createSheet(fileName);
//filling contents of sheet
response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName); OutputStream out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
当我在localhost中运行时,这是有效的。但是当我将应用程序部署到服务器时它不起作用。
任何人都可以告诉我哪里出错了。