Skip to content

Instantly share code, notes, and snippets.

@RoseCrime
Last active May 27, 2018 21:09
Show Gist options
  • Save RoseCrime/2acd63a715a5ecec5702f3dcffdf71e1 to your computer and use it in GitHub Desktop.
Save RoseCrime/2acd63a715a5ecec5702f3dcffdf71e1 to your computer and use it in GitHub Desktop.
xlsx make file
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