I am having trouble trying to read an .xlsx file in my meteor application with xlsx. I tried to do this:
const XLSX = require('xlsx');
/* Makes it possible to use the codes!*/
Template.Planning.onCreated(function() {
var workbook = XLSX.read('planning.xlsx', {type:'binary'});
var first_sheet_name = workbook.SheetNames[0];
var address_of_cell = 'A22';
/* Get worksheet */
var worksheet = workbook.Sheets[first_sheet_name];
/* Find desired cell */
var desired_cell = worksheet[address_of_cell];
/* Get the value */
var desired_value = (desired_cell ? desired_cell.v : undefined);
console.log(desired_value);
});
The file planning.xlsx is located in the same folder as my Planning.js file. However this code returns undefined, but when I open planning.xlsx, the cell A22 contains the name Dave. What am I doing wrong?