The code :
var workbook = XLSX.read(data, {type: 'binary'});
var first_sheet_name = workbook.SheetNames[0];
var worksheet = workbook.Sheets[first_sheet_name];
var k=1
var desired_cell = worksheet['A'+k].w;
The above code runs fine But :
for (var i = 1; i <= 50; i++) {
var obj = {};
var cell = (worksheet[('A'+i)]).w;
obj.PickUpDate = cell;
obj.PickUpTimeSlot = cell;
obj.PickUpAddress = cell;
obj.DeliveryAddress = cell;
obj.BoxType = cell;
array.push(obj);
}
this code gives an error:
Uncaught TypeError: Cannot read property 'w' of undefined
at FileReader.reader.onload
The line:
var cell = (worksheet[('A'+i)]).w;
is fine as I can print the 'cell' to console.
Both the snippet are in FileReader.reader.onload
function.
I am using xlsx package https://github.com/SheetJS/js-xlsx
What is wrong with that code?