1

CSV として生成する必要があるリストがあります。ここにあります:

[101, true, P, b, br, 2020], [101, true, P, 20, br, 2020], [101, true, P, b, breach, 2020]

そして、私はそれを変換するためにこれを書きました:

var link = document.createElement('a');
link.id = 'download-csv';
link.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(queries.toString().replaceAll("[","").replaceAll("],","\\r\\n").replaceAll(",",";").trim().replaceAll("]","")));
link.setAttribute('download', 'yourfiletextgoeshere.csv');
document.body.appendChild(link);
document.querySelector('#download-csv').click();

生成された CSV ファイルは次のようになります。

101; true; P; b; br; 2020\r\n101; true; P; 20; br; 2020\r\n101; true; P; b; br; 2020

行を分割する代わりに\r\n、文字列であるかのように続けます。

4

1 に答える 1