bblog
bblog copied to clipboard
URL.createObjectURL(new Blob[...]) CSV 乱码问题
trafficstars
http://blog.csdn.net/leonzhouwei/article/details/8447643
原因是 Excel 以 ANSI 格式打开,不会做编码识别。
解决方法
function downloadCSV(fileName, content) {
let a = document.createElement('a');
let file = URL.createObjectURL((new Blob(['\uFEFF' + content], { type: 'text/csv;charset=utf-8' })));
a.href = file;
a.download = `${fileName}.csv`;
a.click();
}
http://stackoverflow.com/questions/19492846/javascript-to-csv-export-encoding-issue