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