Skip to content

Instantly share code, notes, and snippets.

@xgenvn
Created September 9, 2022 09:27
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 xgenvn/229160f83cd8a8b466c3dad41b9a873b to your computer and use it in GitHub Desktop.
Save xgenvn/229160f83cd8a8b466c3dad41b9a873b to your computer and use it in GitHub Desktop.
Parse XLSX with headers
import * as XLSX from 'xlsx/xlsx.mjs'
import * as fs from 'fs';
XLSX.set_fs(fs);
function main() {
const opts = {
}
const workbook = XLSX.readFile('excel_multiple_rows.xls', opts)
const first_ws = workbook.Sheets[workbook.SheetNames[0]];
const data = XLSX.utils.sheet_to_json(first_ws, {
header: "A"
})
const [sheetDescription, headers, ...sheetData] = data
console.log(sheetData)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment