Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sheetJs - no output for empty cell

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 ));
}
like image 464
Padma Avatar asked Sep 02 '25 02:09

Padma


1 Answers

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 ("")
like image 75
Marko Sikman Avatar answered Sep 04 '25 16:09

Marko Sikman