1
是否可以保存工作簿并将其保存,而无需将编辑的文件复制到基本文件上?以不同名称保存编辑/写入工作簿
这里是我的代码:
File file = new File("base.xlsx");
Workbook workbook = WorkbookFactory.create(file);
Sheet sheet = workbook.getSheet("data");
...
//creating rows and cells, writing stuff
...
//saving
FileOutputStream fos = new FileOutputStream("edited.xlsx");
workbook.write(fos);
workbook.close();
fos.close();
//now both the base.xlsx and edited.xlsx contain all the new and previous data - and are exactly the same size
//using only
workbook.close();
//the workbook file size changes (approximately to the same as edited.xlsx) and the timestamp is current
//BUT the data doesn't get saved
唯一的可能,我知道的是用一个InputStream(但后来我得到了内存(10MB .xlsx文件和2GB的堆空间))
令人困惑的部分是:为什么base.xlsx文件被编辑,如果我把它写出到另一个文件?
谢谢你的解释! – Beig