Merged cells Xlsx to json parsing
TSergey123 opened this issue · comments
Hey everyone,
Thanks a lot for your library, appreciate the work that you have done, but I have an unusual problem.
what can I do with merged cells in one line?
my code:
const readXlsxFile = require("read-excel-file/node");
const schema = {
"ClientCateg": {
prop: "ClientCateg",
type: String,
},
"Place": {
prop: "Place",
type: String,
},
"Price": {
prop: "price",
type: {
"SummFrom": {
prop: "SummFrom",
type: String,
},
"SummTo": {
prop: "SummTo",
type: String,
},
},
},
};
readXlsxFile("template-blanks1.xlsx", { schema }).then(({ rows, errors }) => {
errors.length === 0;
console.log(rows);
});
my result:
[ { ClientCateg: firstCateg', Place: 'Inside', price: { summFrom: '100000', summTo: '2999999.99' } }, { price: { summFrom: '3000000', summTo: '7000000' } }, { ClientCateg: 'SecondCateg', Place: 'Outside', price: { summFrom: '100000', summTo: '2999999.99' } }, { price: { summFrom: '3000000', summTo: '7000000' } } ]
As you can see, for merged cells in one line, it creates a new object, but I need all data from a row, to be in one object
Hi. It's strange that it doesn't return all data. I'd assume it would return every row (with duplicates).
You could provide the file and I could maybe hypothetically look at it in some future, or maybe not.
You could debug it yourself: the library's code is pretty simple.
Incredible, you answered instantly)
I have already tried more than a dozen libraries and everyone has this problem. Even if I manage to return all the rows, they will return null
{ ClientCat: 'FirstCat',
Place: 'Inside',
List: '*',
Acceptable: 'true',
Program: Special,
Code: 'I1',
Name: Product 'sort'
},
{
ClientCat: null, productCode: null,
CreditType: null,
SummFrom: null,
SummTo: null,
TermFrom: 1,
undefined: 360,
PvMin: 15,
PvMid: 19.99,
PVMax: 20,
Procent: null },
I have already tried more than a dozen libraries and everyone has this problem. Even if I manage to return all the rows, they will return null
That's how Excel file format works: the value is only written in the top row in a group, and then all other rows have null
s. The cell being vertically expanded is just a visual effect.
Yes it is. But maybe there is some way to adapt to this visual effect?
I think there could be: a library could duplicate the top row value onto the other rows when it sees that a cell has a "col span" attribute.