
To export data in node js we will use exceljs module. So let's direct jump into the code. Let's first install this module using below command
npm i exceljs
now create file name as exportToExcel.js and copy paste below code
const excel = require("exceljs");
function exportExcel() {
let workbook = new excel.Workbook();
let worksheet = workbook.addWorksheet("Straw Hat");
let exportData = [];
exportData.push({
...