Created
November 20, 2020 19:31
-
-
Save th91vi/49dea4919f8da2a468e480fa7dedc641 to your computer and use it in GitHub Desktop.
Function to generate on the fly Excel spreadsheets, using Sheetjs/xlsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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