I am using Javascript to create a CSV file for download.
Until May 22, Chrome still uploaded the file with the specified name. However, today I discovered that the downloaded files are called “downloads” and do not have the .csv extension.
This problem does not exist in Firefox!
Here is a fiddle with a Javascript sample:
var A = [['n','sqrt(n)']]; // initialize array of rows with header row as 1st item for(var j=1;j<10;++j){ A.push([j, Math.sqrt(j)]) } var csvRows = []; for(var i=0,l=A.length; i<l; ++i){ csvRows.push(A[i].join(',')); // unquoted CSV row } var csvString = csvRows.join("\n"); var a = document.createElement('a'); a.href = 'data:text/csv;charset=utf-8;base64,' + window.btoa(csvString); a.target = '_blank'; a.download = 'myFile.csv'; document.body.appendChild(a); a.click();
javascript jquery html google-chrome csv
Koshien
source share