json2xls icon indicating copy to clipboard operation
json2xls copied to clipboard

YOu dont need this lib anymore

Open wandersonsousa opened this issue 1 year ago • 1 comments

Just use the npm package xlsx, and:

import xlsx from "xlsx";

export function saveJsonToSheet(data, path) {
  console.log("building xlsx for data", data);
  const workbook = xlsx.utils.book_new();
  const worksheet = xlsx.utils.json_to_sheet(data);
  xlsx.utils.book_append_sheet(workbook, worksheet, "Sheet1");

  // Write xlsx data to a file (e.g., output.xlsx)
  xlsx.writeFile(workbook, path);
  console.log("xlsx file created successfully.");
}

wandersonsousa avatar Dec 29 '23 05:12 wandersonsousa

This.

xlsx (the npm package for SheetsJS) is the main dependency for most newer json to xls libraries, just learn and use the xlsx workflow and you'll be good to do any and all operations you need to build and work with excel files in javascript/typescript

EDIT: json2xls broke recently due to a deep dependency releasing a breaking change, another reason to move to this way of doing things.

CmD0 avatar Jun 18 '24 19:06 CmD0