Skip to content

Instantly share code, notes, and snippets.

@th91vi
Created November 20, 2020 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save th91vi/49dea4919f8da2a468e480fa7dedc641 to your computer and use it in GitHub Desktop.
Save th91vi/49dea4919f8da2a468e480fa7dedc641 to your computer and use it in GitHub Desktop.
Function to generate on the fly Excel spreadsheets, using Sheetjs/xlsx
import xlsx from 'xlsx';
const generateSpreadsheet = (data) => {
const data = xlsx.utils.json_to_sheet(data);
const workBook = xlsx.utils.book_new();
xlsx.utils.book_append_sheet(workBook, data, 'example spreadsheet');
xlsx.writeFile(workBook, 'example spreadsheet.xlsx');
};
export default generateSpreadsheet;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment