-
Notifications
You must be signed in to change notification settings - Fork 5
Convert Excel to JSON & JSON to Excel
Manujaya edited this page Jul 21, 2021
·
1 revision
"npm install xlsx"const wb = xlsx.readfile(./<file_name>.xlsx);const wb = wb.Sheets['<name_of_the_sheet>'];const data = xlsx.utils.sheet_to_json(ws);fs.writeFileSync("./datajson.json", JSON.Stringfy(newData, null, 2)); //datajson.json is the file namelet content = JSON.parse (fs.readFileSync ('./datajson.json', 'utf8'));let newWB = xlsx.utils.book_new();let newWS = xlsx.utils.json_to_sheet(content);xlsx.utils.book_append_sheet (newWB, newWS, 'new data'); // new data is the name of the sheetxlsx.writeFile(newWB, "newExcel.xlsx");