It appears that one can open an Excel file using
Workbook wb = WorkbookFactory.create(myFile);
...but then, even if no changes are made, a call to
wb.close();
...to release resources will result in the file on the file system being updated (at least the timestamp will be, if nothing else). The only way I have found around this is to specify that the Workbook should be created "read only" with
Workbook wb = WorkbookFactory.create(myFile, true);
What I'm trying to do is the following:
Is this possible? I've tried many things, but can't seem to get it to work. If I don't want the original file timestamp updated, it seems I have to open the Workbook as read only. But then I can't modify it in memory for a subsequent write to a new file. Catch-22.
[BTW, I'm creating the Workbook from a File rather than a stream, as I understand it is more efficient. If I used a stream I could possibly get around this issue by closing the stream myself. Also, I'm working with XLSX/XLSM not XLS files.]
Thoughts? Thanks!
Options could be:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With