Last active
May 27, 2018 21:09
-
-
Save RoseCrime/2acd63a715a5ecec5702f3dcffdf71e1 to your computer and use it in GitHub Desktop.
xlsx make file
This file contains hidden or 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
const xlsx = require('xlsx') | |
/* original data */ | |
let data = [ | |
{"name":"John", "city": "Seattle"}, | |
{"name":"Mike", "city": "Los Angeles"}, | |
{"name":"Zach", "city": "New York"} | |
] | |
/* make the worksheet */ | |
let ws = XLSX.utils.json_to_sheet(data) | |
/* add to workbook */ | |
let wb = XLSX.utils.book_new() | |
xlsx.utils.book_append_sheet(wb, ws, "People") | |
/* generate an XLSX file */ | |
xlsx.writeFile(wb, "sheetjs.xlsx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment