将数据从 Oracle SQL Developer 导出到 Excel .xlsx

IAm*_*son 5 sql oracle excel xlsx

我有一个小项目,需要将 Oracle SQL Developer 中的数据导出到 Excel(使用命令而不是 SLQ Developer 中的工具),然后创建一个图表。使用“假脱机”我可以导出到 csv 很好(但不能在 csv 中制作图形)但是当我尝试导出到 xlsx 时它会破坏整个 excel 表说

"Excel cannot open the file "ExcelFile.xlsx" because the file format or file extention 
       is not valid. Verify that the file has not been corrupted and that the 
       file extension mathces the format of the file."
Run Code Online (Sandbox Code Playgroud)

这是我在 SQL Developer 中使用的代码。

spool FileLocation\ExcelFile.xlsm
SELECT * FROM Table;
spool off;
Run Code Online (Sandbox Code Playgroud)

有什么方法可以阻止数据损坏,还是有其他方法可以将数据导出到 .xlsx 文件?

tha*_*ith 5

呜呜呜。

set sqlformat csv
spool c:\file.sql
select * from table;
spool off;
Run Code Online (Sandbox Code Playgroud)

然后用excel打开文件。

或者

以交互方式运行您的查询。

右键单击网格,导出 > XLSX。打开文件。

Spool 只将查询输出写入文件,它不会查看文件扩展名并找出此时如何写入输出。

因此,您要么必须通过查询自己编码,要么使用我们支持的格式输出之一

SET SQLFORMAT
  CSV
  JSON
  DELIMITED
  XML
  HTML
  INSERT
  LOADER
Run Code Online (Sandbox Code Playgroud)

使用“help set sqlformat”获取帮助。


paz*_*zio 3

嗨,sql 开发人员,据我所知,导出是使用 sqlplus(代码相同),所以也许还有其他方法,但这个应该足够好

我会尝试将第一行更改为如下所示:

spool ExcelFile.xls
Run Code Online (Sandbox Code Playgroud)

可能你还需要打开

SET MARKUP HTML ON
Run Code Online (Sandbox Code Playgroud)

http://www.orahow.com/2015/09/spool-sqlplus-output-to-excel-format.html

无论如何,有一个解决方法 - 您可以生成 .CSV 文件,然后在 Excel 中打开它并另存为 .xlsx 文件