2

I am using sheetjs. The empty cell is not getting populated in the json object including the header. I need that information also if a column is not entered. Here is my code:

workbook.SheetNames.forEach((sheetName) => {
    let XL_row_object = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {defval:""});
    console.log( JSON.stringify(XL_row_object ));
}
Padma
  • 21
  • 1

2 Answers2

0

I was having the same issue and I solved this problem with this:

XLSX.readFile('file', {sheetStubs:true})

aribeiro
  • 3,854
  • 4
  • 27
  • 41
burakkp
  • 23
  • 9
0

You can solved it with this part, at the begining, when you are including your SheetJS:

**const data = xlsx.utils.sheet_to_json((ws),{defval:""});**

  • data is just a const which holds conversion from sheet to json
  • ws is the name of our sheets which we are using for conversion and manipulation
  • defval presents empty cell values. In our case it is an empty string ("")
Marko Sikman
  • 168
  • 1
  • 4