Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create a true Excel file from PL/SQL?

Aaron L.Jun 30 2021

I don't like how we currently create Excel files from PL/SQL or SQL. It is 2021 and I feel there has to be a way to create an xlsx file that MS Excel knows is legit. Our system sends these files/reports out to our users to use. Here are our current methods:
"set markup html on" and spool it to an .xls file. When opening that file, Excel says "The file format and extension of '**.xls' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?" I feel like that makes our department look inept.
Create an xml file using 2003 Excel xml. If we spool that to an .xls file, we get the same error as method 1. If we spool it to an xml file, it is a pain for a lot of people to open in Excel. I don't want to set my default program to Excel for xml files and using "Open With" doesn't allow Excel to open it. I can't find anything in the last 15 years that says to use this method.
Export to csv or html. That's fine if the user is fluent in importing different formats and we don't care about formatting any columns (csv).
Users are always requesting "Can't you just send it to me in Excel?" We can manually open it in Excel and save it, but we have automated reports for a reason.
Are there objects in our 19c database (like possibly APEX) that can do this using PL/SQL?

This post has been answered by James Su on Jun 30 2021
Jump to Answer
Comments
Post Details
Added on Jun 30 2021
5 comments
12,925 views