File.DirApp returns the application folder which is protected by Windows as read-only. The recommended way is to use xui.DefaultFolder
Thanks but first of all its not true that the path returned via File.DirApp is in any way write-protected by Windows, it simply returns the path to the .jar/ exe in the bin folder in a packed version.
It may happen if you happen to put your jar or exe somwhere in "Progam Files" that needs elevation but I'm not doing that.
Other than that I mentioned that in both cases (running from "Main"/ running from a class) an .xlsx is even generated, but its a bit shorter when its generated from the class and Excel deems it corrupted.
Upload a small project showing the problem.
It will work fine in a Classmodule. Maybe it does not work in a Codemodule.
Seeing a project will be help to understand the problem.
If you got any Error you should have posted them.
There weren't any errors, otherwise I would have had a starting point to investigate.
I started making a sample project as you recommended and that brought me to the issue:
XLUtils must be .Initialize'd but didn't throw any error.
The example I modified did this but I never implemented this in my own class initializer... so there we go - Problem found and solved.
Also the example was set to Release mode what didn't throw the "... must be initialized first" error... Which is a pretty big thing I would have expected to be thrown in release as well actually.
Anyway, its Friday and a bit hot around here so....
Thanks and a great weekend.