我有一个小项目,需要将 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/