1

Im trying to export String data to CSV using unicode in JavaScript using UTF-8 and \uFEFF. 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();
   }

1 Answer 1

2

the answer is in this link Javascript to csv export encoding issue the bottom line is "data:attachment/csv;charset=utf-8,%EF%BB%BF" + {{yuourCsvString}};

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.