Im trying to export String data to CSV using unicode in JavaScript using UTF-8 and \. The problem is when the CSV file build he take the string after comma , and the first cell filled with this string : "Content-Disposition:attachment;filename="+filename+"\\ ," " . I tried to change the position of the charset to the end, but the fileName must be in the end of the link.
Any ideas ?
thanks!
downloadCampaingnCsv: function(campaignIds,filename, url){
var s = new Server();
var response = s.sendJSON(ApiBaseUrl + url,'POST',campaignIds);
var csvContent = "data:text/csv;charset=utf-8,/uFEFF;Content-Disposition:attachment;filename="+filename+"\ ," ;
if (response != "No Data!"){
var encodedUri = csvContent +encodeURI(response);
} else {
var encodedUri = "data:text/csv;filename="+filename+"\ ," + encodeURI(response);
}
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
link.click();
}
答案是在此Javascript到csv导出编码的链接中,最底行是“ data:attachment / csv; charset = utf-8,%EF%BB%BF” + {{yuourCsvString}};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.