Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

electron write to csv

ipcMain.on("write-csv-data", async (event, filePath, data) => {
    const csvWriter = createCsvWriter({
      path: `${filePath}`, // Don't ask why. This is how i got it to work.
      header: [
        { id: "name", title: "First Name" },
        { id: "timezone", title: "Timezone" },
      ],
    });
    csvWriter
      .writeRecords(data)
      .then(() => {
        console.log(`...Done (${filePath})`);
      })
      .catch((err) => {
        console.log(err);
      });
});
 
PREVIOUS NEXT
Tagged: #electron #write #csv
ADD COMMENT
Topic
Name
2+9 =