我写了一个js代码,将数据导出到.csv表中。我的问题是,当我打开文件时,Excel无法显示č或š这样的捷克变音符号。有人可以帮助我吗?
function exportData(){
console.log("Started export to CSV.");
const rows = [
["Procesor" + " " + String(window.localStorage.getItem("CPU"))],
["RAM" + " " + String(window.localStorage.getItem("RAM"))],
["Displej" + " " + String(window.localStorage.getItem("display"))],
["Baterie" + " " + String(window.localStorage.getItem("battery"))],
["Grafická karta" + " " + String(window.localStorage.getItem("GPU"))],
];
let csvContent = "data:text/csv;charset=utf-8,"
+ rows.map(e => e.join(",")).join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "parametry.csv");
document.body.appendChild(link); // Required for FF
link.click(); // This will download the data file named "my_data.csv".
}`
答案 0 :(得分:1)
在我的Mac上,UTF-8 CSV可以正确显示,因此这是Excel中的错误。
您可能会对SO有类似的问题,但这是一个摘要:
相信原始答案:Is it possible to force Excel recognize UTF-8 CSV files automatically?