I am not sure if you code using RPG, but if so you can use the HSSF API’s created by Scott Klement to create fully formatted Excel spreadsheets from an RPG program. This includes formulas, as well as lots of other formatting options. There are three articles that he wrote to describe the basics. If you are interested search for HSSF in this wesbite. I know I posted links to the articles on another thread.
I takes some time to understand and set up (the code is downloadable with a working exmaple), but it is the best approach I found for allowing you to create truly formatted excel spreadsheets (not .csv files).