JSON missing columns where the first value for a labelled column is empty #864
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#864
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Unlike the other output formats, when outputting to JSON and the excel column does not have a value in the first row after the row header, that column is not included in the JSON.
I want the same problem
I have proposed a fix in this PR:
https://github.com/SheetJS/js-xlsx/pull/918
I'm on version 0.11.17 and still have this problem, has it been resolved?
@paishin can you share a file?
Hey there @reviewher, I am sending you two files the first one works fine, the second one has one field 'ID Issue Country' empty and it does not work because its value is missing from the results.
This one works:
persons.single.xlsx
[ { 'Customer No.': '84613', 'First name': 'Yiannis', 'Last name': 'Kostis', Sex: 'M', 'Type of ID': 'PN', 'ID Number': '123456-789', 'ID Is Certified': 'FALSE', 'ID Expiration Date': '12/10/99', 'ID Issue Country': 'NULL', 'Birth Date': '4/5/46', 'Creation Date': '2/5/97', 'Life Cycle': 'AC', 'Phone 1': '+22334455', 'Phone 2': 'NULL', 'Mobile 1': '+35799887766', 'Mobile 2': 'NULL', 'Fax 1': 'NULL', 'Fax 2': 'NULL', Email: 'yianni@kostis.com', 'Address Line 1': 'Koukouroukou 32, Flat 1', 'Address Line 2': 'NULL', 'Zip Code': '2222', City: 'Nicosia', Country: 'Cyprus', 'Country ISO': 'CY', 'Last Balance': '1234.56', 'Questionnaire Submitted': 'FALSE', 'LRS Risk': 'NULL', 'Address has proof': 'TRUE', 'Nationality Country': 'NULL', 'Country of Birth': 'NULL', Income: '15000', 'Income Source': 'Salary', 'Income Status': 'Verified' } ]
This one fails:
persons.single (1).xlsx
[ { 'Customer No.': '84613', 'First name': 'Yiannis', 'Last name': 'Kostis', Sex: 'M', 'Type of ID': 'PN', 'ID Number': '123456-789', 'ID Is Certified': 'FALSE', 'ID Expiration Date': '12/10/99', 'Birth Date': '4/5/46', 'Creation Date': '2/5/97', 'Life Cycle': 'AC', 'Phone 1': '+22334455', 'Phone 2': 'NULL', 'Mobile 1': '+35799887766', 'Mobile 2': 'NULL', 'Fax 1': 'NULL', 'Fax 2': 'NULL', Email: 'yianni@kostis.com', 'Address Line 1': 'Koukouroukou 32, Flat 1', 'Address Line 2': 'NULL', 'Zip Code': '2222', City: 'Nicosia', Country: 'Cyprus', 'Country ISO': 'CY', 'Last Balance': '1234.56', 'Questionnaire Submitted': 'FALSE', 'LRS Risk': 'NULL', 'Address has proof': 'TRUE', 'Nationality Country': 'NULL', 'Country of Birth': 'NULL', Income: '15000', 'Income Source': 'Salary', 'Income Status': 'Verified' } ]
@paishin , sorry, my fix does not address data missing in first data row (second row of the file), but the whole column missing when first header row had no name (first row of the file).
I so inappropriately linked my fix to this issue. Feel free to re-open it.
@paishin you are describing a different situation. The second worksheet has no assigned value in cell I2, so by default the converter does not add a field for that column. If a subsequent row does have a value in that column, the value will be included. If you really want a default value, the option in
sheet_to_json
isdefval
.Here's a small example:
If you need to merely recover the original headers, we could theoretically attach it as a named property of the result. It would be a 1-line change near the end of
sheet_to_json
: