I’m writing pl/sql procedure that exports data from Oracle to Excel. I need data formatting so I can’t use CSV. I’ve already tried with XML but it generates too large files
There is another project ORA_EXCEL (www.oraexcel.com) that can produce Excel documents from Oracle database using only PL/SQL.
From: MSDN. If you want your worksheet to be portable and not to rely on System DSNs you can connect using a connection string like:
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=OraOLEDB.Oracle.1;Password=<PASSWORD>;Persist Security Info=True;User ID=<USER ID>;Data Source=<DATABASE NAME>"
cnn.Open
... then use Moleboy's solution.
Your problem seems similar to a thread here in SO (Writing in ExcelSheet using UTL_FILE package in Oracle.) and I was able to find a simple solution to this problem recently.
i used a package called as_xlsx
created by Anton Scheffer, (Create an Excel-file with PL/SQL) and did a few modifications so it creates multiple sheets inside a single Excel Workbook by putting it through a Loop.
It also supports some basic formatting such as Cell Color, Font Style, Font Size, Borders, etc. Its pretty nifty.
(Create an Excel File (.xlsx) using PL/SQL).
Hope this helps!
There is a product called SQL*XL which allows you to run sql queries from within Excel, and the results appear within the worksheet (it can also update).
It is commercial, not free, but is only about €50, so not expensive. I use it quite a lot
Instead of creating Excel or HTML files on Oracle server, you can fetch Oracle data to existing Excel document via ODBC or OLEDB. The shortcoming is, that you should be careful with user permissions.
https://www.youtube.com/watch?v=Adz0zZFePf8
You could save a (small) Excel sheet as html in Excel, and then reproduce that format.