Für alle Sprachen funktioniert
function convertToCsv(fName, rows) {
var csv = '';
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
for (var j = 0; j < row.length; j++) {
var val = row[j] === null ? '' : row[j].toString();
val = val.replace(/\t/gi, " ");
if (j > 0)
csv += '\t';
csv += val;
}
csv += '\n';
}
// für UTF-16
var cCode, bArr = [];
bArr.push(255, 254);
for (var i = 0; i < csv.length; ++i) {
cCode = csv.charCodeAt(i);
bArr.push(cCode & 0xff);
bArr.push(cCode / 256 >>> 0);
}
var blob = new Blob([new Uint8Array(bArr)], { type: 'text/csv;charset=UTF-16LE;' });
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, fName);
} else {
var link = document.createElement("a");
if (link.download !== undefined) {
var url = window.URL.createObjectURL(blob);
link.setAttribute("href", url);
link.setAttribute("download", fName);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
}
}
}
convertToCsv('download.csv', [
['Auftrag', 'Sprache'],
['1', 'Englisch'],
['2', 'Español'],
['3', 'Français'],
['4', 'Português'],
['5', 'eština'],
['6', 'Slovenšina'],
['7', 'Ting Vit'],
['8', 'Türkçe'],
['9', 'Norsk bokmål'],
['10', ''],
['11', ''],
['12', ''],
['13', ''],
['14', ''],
['15', ''],
['16', ''],
['17', ''],
['18', ''],
['19', ''],
['20', ''],
['21', ''],
['22', ''],
['23', ''],
])