Created
September 9, 2022 09:27
-
-
Save xgenvn/229160f83cd8a8b466c3dad41b9a873b to your computer and use it in GitHub Desktop.
Parse XLSX with headers
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 * 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