The source is an excel file. I parsed and looped through the columns assigning headers. So far, this works fine. However I can't seem to access this data outside of the for loop as it comes up as "undefined" every time.
I am using the xls package and this is in javascript.
Changed the variable names to post the code due to sort of sensitive info. Let me know if there's any way I can clarify better. Thanks!
let data = []
for (let fname of fileList) {
if (file_count > 1) {
continue
} else {
}
let excelFile =
XLSX.readFile(`FILE.xlsm`,
{
cellDates: true,
});
log('FILENAME', fname)
let sheet_name;
for (let sheet in excelFile.Sheets) {
sheet_name = sheet
log('SHEET NAME', sheet)
}
let array = XLSX.utils.sheet_to_json(excelFile.Sheets[sheet_name],
{
header:
['HEADER_1',
'HEADER_2',
'HEADER_3']
} );
log('array', array[0].HEADER_1)
for(let i = 0; i<array.length; i++){
let data = {
Obj_1: array[i].HEADER_1,
Obj_2: array[i].HEADER_2,
Obj_3: [i].HEADER_3
}
}
}