Is it necessary to close the open file manually before I start updating data using Apache POI? I'm getting error "The process cannot acess the file because it is used by another process". Or is there any way if Excel file is open and still I can update it using Java Apache POI?
CodePudding user response:
No.
And if you are a window user than Windows itself will not let you do this. Nothing in your code will let you do so, I'm afraid. You need to close the file in Excel first.
I am assuming from your description that you've got the file open yourself, in Excel. You might not be. However something else certainly does - it could be another instance of your Java application, for example. Even make sure stuff like Windows Explorer isn't accessing/using the file, e.g. to check attributes. And until you rule that out, as mentioned Windows itself will block you accessing it.