xlsx to json with empty cells xlsx to json with empty cells json json

xlsx to json with empty cells


can you replace content: XLSX.utils.sheet_to_json(workbook.Sheets[sheet]) with content: XLSX.utils.sheet_to_json(workbook.Sheets[sheet], {defval:""}) in your code and try again?


This should work. Working example

let XLSX = require('xlsx');const workbook = XLSX.readFile(filename);const sheet_name_list = workbook.SheetNames;let jsonPagesArray = [];sheet_name_list.forEach(function(sheet) {        const jsonPage = {            name: sheet,            content: JSON.parse(JSON.stringify(XLSX.utils.sheet_to_json(workbook.Sheets[sheet],{defval:""})))        };        jsonPagesArray.push(jsonPage);    });console.log(jsonPagesArray[0].content);


You can use

XLSX.utils.sheet_to_json(worksheet , {defval:""})