Oracle to Excel - PL/SQL export procedure

前端 未结 11 1185
轮回少年
轮回少年 2020-12-08 17:56

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

相关标签:
11条回答
  • 2020-12-08 18:08

    There is another project ORA_EXCEL (www.oraexcel.com) that can produce Excel documents from Oracle database using only PL/SQL.

    0 讨论(0)
  • 2020-12-08 18:09

    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.

    0 讨论(0)
  • 2020-12-08 18:13

    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!

    0 讨论(0)
  • 2020-12-08 18:14

    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

    0 讨论(0)
  • 2020-12-08 18:16

    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

    0 讨论(0)
  • 2020-12-08 18:26

    You could save a (small) Excel sheet as html in Excel, and then reproduce that format.

    0 讨论(0)
提交回复
热议问题