Сделайте файл из массива сохранения JS
async function saveCSV () {
// (A) ARRAY OF DATA
var array = [
["Job", "job@doe.com", "123456"],
["Joe", "joe@doe.com", "234567"],
["Joi", "joi@doe.com", "345678"],
["Jon", "jon@doe.com", "456789"],
["Jou", "jou@doe.com", "987654"],
["Joy", "joy@doe.com", "876543"],
];
// (B) ARRAY TO CSV STRING
var csv = "";
for (let row of array) {
for (let col of row) { csv += col + ","; }
csv += "\r\n";
}
// (C) CREATE BLOB OBJECT
var myBlob = new Blob([csv], {type: "text/csv"});
// (D) FILE HANDLER & FILE STREAM
const fileHandle = await window.showSaveFilePicker({
suggestedName : "demo.csv",
types: [{
description: "CSV file",
accept: {"text/csv": [".csv"]}
}]
});
const fileStream = await fileHandle.createWritable();
// (E) WRITE FILE
await fileStream.write(myBlob);
await fileStream.close();
}
Wild Weasel