sisa-crawl/saveResultsToExcel.js

11 lines
423 B
JavaScript
Raw Normal View History

const xlsx = require("xlsx");
function saveResultsToExcel(data, filename) {
const workbook = xlsx.utils.book_new(); // Create a new workbook
const worksheet = xlsx.utils.json_to_sheet(data); // Convert data to worksheet
xlsx.utils.book_append_sheet(workbook, worksheet, "Results"); // Add worksheet to workbook
// Write workbook to file
xlsx.writeFile(workbook, filename);
}
module.exports = saveResultsToExcel;