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

标签 sql excel oracle xlsx

我有一个小项目,需要将 Oracle SQL Developer 中的数据导出到 Excel(使用命令而不是 SLQ Developer 中的工具),然后创建一个图表。 使用“spool”,我可以很好地导出到 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."

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

spool FileLocation\ExcelFile.xlsm
SELECT * FROM Table;
spool off;

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

最佳答案

不,不。

set sqlformat csv
spool c:\file.sql
select * from table;
spool off;

然后在 Excel 中打开该文件。

或者

以交互方式运行查询。

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

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

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

SET SQLFORMAT
  CSV
  JSON
  DELIMITED
  XML
  HTML
  INSERT
  LOADER

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

关于sql - 将数据从 Oracle SQL Developer 导出到 Excel .xlsx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44724970/

相关文章:

excel - 控制Excel时间格式输入/输出

oracle - 从 CLOB 中假脱机数据

java - 使用 sysdate 更新日期列会引发 Oracle 中的唯一约束冲突。由于日期是主键而随机发生

Python:刷新工作表中的数据透视表

java - Java 中的 Excel 文件导出

sql - 获取列中的特定行值

c# - LINQ to Entities 无法识别方法 'System.String ToString()' 方法,并且该方法无法转换为存储表达式

SQL Server : Canonical way to get a substring from a particular index to the end of the string?

php - 需要mysql select data where until的解决方案

mysql - 将包含特定日期的不常见值的表转换为包含一段时间内所有日期的表