Oracle 到 Excel - PL/SQL 导出程序

2021-12-24 00:00:00 excel html oracle plsql vbscript

我正在编写将数据从 Oracle 导出到 Excel 的 pl/sql 过程.我需要数据格式,所以我不能使用 CSV.我已经尝试过使用 XML,但是当我想导出时它会生成太大的文件,例如70000 行 50 列(几乎 300 MB!!!).

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 when I want to export e.g. 70000 rows with 50 columns (almost 300 MB!!!).

这就是我决定使用 HTML 标签生成 XLS 文件的原因——它比 XML 小,我必须直接定义一些特殊列的格式(字符串、数字和日期由 Excel 自动格式化).非常简单方便,但我不能定义多个工作表.

That’s why I decided to use HTML tags to generate XLS file – it is smaller than XML and I must directly define format of only some special columns (strings, numbers and dates are formatted automatically by Excel). It’s very simple and convenient but I can’t define more than one worksheet.

您知道如何在使用 HTML 编写的 Excel 文件中添加/定义多个工作表吗?我试过使用像 <% ActiveWorkbook.Worksheet.Add %> 这样的 VBScript 公式,但它不起作用.

Do you know how to add/define more than one worksheet in excel file written using HTML? I’ve tried to use VBScript formula like <% ActiveWorkbook.Worksheet.Add %>, but it doesn’t work.

推荐答案

您可以通过 ODBC 或 OLEDB 将 Oracle 数据提取到现有 Excel 文档中,而不是在 Oracle 服务器上创建 Excel 或 HTML 文件.缺点是,你应该小心用户权限.

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

相关文章