Closed ghost closed 10 years ago
The default behavior is not to write empty or unspecified cells.
You can try setting sheetStubs to true:
XLSX.readFile('file', {sheetStubs:true})
but it won't always generate cells.
The problem comes from the fact that Excel stores a sparse representation (unless there is some special reason, like a comment, Excel will not store empty cells in XLSX).
Strictly speaking, you can write your own walker. Check the code for the sheet_to_csv function -- it generates the relevant cell addresses, and if the object is not there it will emit an empty string.
Is there any particular reason why you want to include those cells?
Hey, thanks for the feedback. Makes a lot of sense.
I was building a wrapper on top of your module where that behavior was needed. I took your advice and things are all good.
@Moonfuse Did you resolve the issue? If so, please close :)
Solution 1 .Condition "if(h===undefined)continue;" in "xlsx.core.min.js" comment it out.
or do it properly...
Solution 2 . By passing Condition extra param while running this XLSX.utils.sheet_to_json(wb.Sheets[name] , {blankCell : false}). add a condition on line no. 19150 "if(defval === undefined && blankCell) continue;" in file xlsx.js etc..
I tried with XLSX.utils.sheet_to_json(wb.Sheets[name] , {blankCell : false}) but i am still getting blank values for the empty cell. Can you suggest any modifications to make this work
Probably you forgot to add a condition on line no. 19150 "if(defval === undefined && blankCell) continue;" in file xlsx.js etc..
or simply try this hack Solution 1 .Condition "if(h===undefined)continue;" in "xlsx.core.min.js" comment it out.
On Mon, Mar 19, 2018 at 2:53 PM, Ashish Dutta notifications@github.com wrote:
I tried with XLSX.utils.sheet_to_json(wb.Sheets[name] , {blankCell : false}) but i am still getting blank values for the empty cell
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SheetJS/js-xlsx/issues/50#issuecomment-374148436, or mute the thread https://github.com/notifications/unsubscribe-auth/AMBU-kBEiW6R8FZ0hCok0z4BuZv9_Oupks5tf3kIgaJpZM4BnX4U .
Hi,
Did any of you able to find its solution? I am facing the same problem.
Hi, did any one know some way to insert that data into a table?. The issue is I already catch the info from my excel file but I want to see it on my web side and insert them on a table in my database.
anyone find the solution?
anyone find the solution?
You can use the defval: "" option while reading a doc, and it will work.
xlsx.utils.sheet_to_json( workbook.Sheets[workbook.SheetNames[0]], { defval: "" });
Like this, hope it helps.
Blank cells in rows ['value1', ' ', 'value3'] are parsed into an object that does not recognize the blank cell: { A1: {}, C1: {} }
Is this the intended behavior?
If it is, it would be nice to have an option that would include blank cells in the output from .readFile().Sheets.
If it is not, is there a way to read blank cells as well?
Thanks