I'm currently working with an excel document, but I need to get only the table headers name. So far my code looks like this
if(file){
let fileReader = new FileReader();
fileReader.readAsBinaryString(file);
fileReader.onload = (event) =>{
let data = event.target?.result;
let workbook = XLSX.read(data,{type:"binary"});
console.log('WORKBOOK',workbook)
workbook.SheetNames.forEach(sheet => {
let rowObject = XLSX.utils.sheet_to_json(workbook.Sheets[sheet])
console.log('RowObject',rowObject)
setFile(rowObject)
})
}
}
Inside the Sheets object, I can see the cells, including the header name, how can I get only the header row?
You can get headers in the following way.