So i have a birthday excel which looks like this: (Sorry i haven’t found a method to upload the excel data correctly..)
And i want to read my excel with sheet.js but i can’t figure out what i’m missing or doing wrong.
So the Age (“Alter” in my Screenshot) is generated by a simple formular which takes the birthdate and subtracts it from the current date.The birthdate is typed in staticly. Just FYI
Now i have the following code:
const path = require("path");
const xlsx = require("xlsx");
const filePath = path.resolve(__dirname, "Mitarbeiter Geburtstagsliste.xlsx");
const workbook = xlsx.readFile(filePath);
const sheetNames = workbook.SheetNames;
//console.log(workbook.Sheets[sheetNames[0]])
const data = xlsx.utils.sheet_to_json(workbook.Sheets[sheetNames[0]]);
data.map(person => {
console.log(`${person.Name} is ${person.Alter} old!`)
})
And when i console log i get undefined for every param as output, why is that?
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!
undefined is undefined old!