Skip to content

Instantly share code, notes, and snippets.

@dcortesnet
Last active February 14, 2023 12:52
Show Gist options
  • Save dcortesnet/03a23a3850627c6da6deac4fcd7176dc to your computer and use it in GitHub Desktop.
Save dcortesnet/03a23a3850627c6da6deac4fcd7176dc to your computer and use it in GitHub Desktop.
Nodejs lectura de archivo excel
// npm install xlsx
const xlsx = require("xlsx");
const file = xlsx.readFile("./data.xlsx");
let data = [];
let sheets = file.SheetNames; // ["Hoja1", "Hoja2"];
for (let index = 0; index < sheets.length; index++) {
const jsonSheet = xlsx.utils.sheet_to_json(file.Sheets[sheets[index]]);
data.push(jsonSheet);
}
console.log(data);
/**
* [
* { A: "1", B: "2", C: "3" },
* { A: "4", B: "5", C: "6" }
* ]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment