tomfaulhaber / excel-templates

Create Excel workbooks from Clojure code using templates and plain old data
Eclipse Public License 1.0
152 stars 20 forks source link

[Windows] Java Can't delete the Template file => output not created #9

Closed nukecoder closed 9 years ago

nukecoder commented 9 years ago

When attempting the simple example given in the README, I get a stack trace containing:

"Caused by java.io.IOException Couldn't delete C:\Users\xb0g\AppData\Local\Temp\excel-template3952450971130792519.xlsx"

This points to excel-templates.build.clj line 191: (io/delete-file tmpfile).

This is on Windows 7. I've tried it with JRE6 and JRE8. Also I'm attempting this from a CIDER repl, and the template files created are locked (I can't delete them from the file browser) until I exit CIDER.

nukecoder commented 9 years ago

Also, verified the same from standard lein repl, so as to remove any middleware confusion.

tomfaulhaber commented 9 years ago

I should have added this to the readme, but I haven't tested excel-templates on Windows at all. I know, kind of ironic, given the project subject area, isn't it?

I would love it if someone who is using Clojure on Windows to debug this and any other Windows related problems and submit a PR that got the library functioning on Windows.

This one sounds like we might still have the file open through POI when we try to delete it and, since Windows doesn't let you delete open files, we get an exception.

smahood commented 9 years ago

Looking into this right now, it looks like we have to go through OPCPackage before creating the new XSSFWorkbook (from https://poi.apache.org/spreadsheet/quick-guide.html#NewWorkbook). Will try and get it working fully in Windows and submit a PR.

tomfaulhaber commented 9 years ago

I believe @smahood's commit fixes this. Please reopen if there are more problems.