var downloadCsv = function(content, fileName) {
var a = document.createElement('a');
mimeType = mimeType || 'application/octet-stream';
var mimeType = 'text/csv;encoding:utf-8';
var BOM = "\uFEFF";
content = BOM + content;
if (navigator.msSaveBlob) { // IE10
navigator.msSaveBlob(new Blob([content], {
type: mimeType
}), fileName);
} else if (URL && 'download' in a) { //html5 A[download]
a.href = URL.createObjectURL(new Blob([content], {
type: mimeType
}));
a.setAttribute('download', fileName);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} else {
location.href = 'data:application/octet-stream,' + encodeURIComponent(content); // only this mime type is supported
}
// Example data given in question text
var data = [
['A', 'B', 'C', 'Größe', 'Maße', 'ÄÜÖ']
, ['C', 'D', 'E', 'F', 'G', 'H']
];
// Building the CSV from the Data two-dimensional array
// Each column is separated by ";" and new line "\n" for next row
var csvContent = '';
data.forEach(function(infoArray, index) {
dataString = infoArray.join(';');
csvContent += index < data.length ? dataString + '\n' : dataString;
});
downloadCsv(csvContent, 'MyFilename.csv', );
Login