When I started using JETT, I found out that under windows, opening the XLSX file with POI by using the Workbook constructor that takes a File as an argument was keeping a handle on the file even after closing the workbook. I think the handle was only released upon garbage collection, but I wanted to be able to modify the file right after transformation.
I guess that the Transformer method of JETT you are using is also leveraging this POI constructor under the hood.
Since then, I'm using the transform method that takes a Workbook as input, and I make sure to create the Workbook by passing an InputStream that I can close myself after transform() has been called, ensuring that the file isn't locked. I had the same problem when manipulating files with POI only, so I guess the culprit here is POI, not JETT.
The strange point about that is that POI documentation clearly advises to use the File Workbook constructor for better performance ; unfortunately, that doesn't work for me and I'm still using the InputStream one in order to ensure the file doesn't get locked once I'm done with it. I may very well do something wrong, but so far this workaround has done wonders for me.
Cheers,
Etienne.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
I am starting with JETT and face the following problem. Excel file becomes locked for chenging after the
Should I call some closing method to unlock it for further use?
Hi Alexander,
When I started using JETT, I found out that under windows, opening the XLSX file with POI by using the Workbook constructor that takes a File as an argument was keeping a handle on the file even after closing the workbook. I think the handle was only released upon garbage collection, but I wanted to be able to modify the file right after transformation.
I guess that the Transformer method of JETT you are using is also leveraging this POI constructor under the hood.
Since then, I'm using the transform method that takes a Workbook as input, and I make sure to create the Workbook by passing an InputStream that I can close myself after transform() has been called, ensuring that the file isn't locked. I had the same problem when manipulating files with POI only, so I guess the culprit here is POI, not JETT.
The strange point about that is that POI documentation clearly advises to use the File Workbook constructor for better performance ; unfortunately, that doesn't work for me and I'm still using the InputStream one in order to ensure the file doesn't get locked once I'm done with it. I may very well do something wrong, but so far this workaround has done wonders for me.
Cheers,
Etienne.