0

I am using exceljs to fetch data from excel. I have written the below code. I am able to get the values inside the rows. But, I am not understanding how to get the column names.

let workbook = new ExcelJs.Workbook();
  workbook.xlsx.load(edata).then(async function(wb){
    wb.eachSheet((sheet, id) => {
      sheet.eachRow({ includeEmpty: false }, function(row, rowIndex) {
      console.log(row.values)
      })
    })
})

Please help me in fetching the column names. Thanks in advance!!

1 Answer 1

1

Try using XLSX.utils.sheet_to_json :

const [columns] = XLSX.utils.sheet_to_json(workbook.Sheets[YOUR_SHEET_NAME], { header: 1 });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.