Open dotnetshadow opened 3 years ago
Hi there,
A great library. I was wondering how I could read various ranges from the same sheet:
At the moment I have the following:
const excelToJson = require('convert-excel-to-json'); const result = excelToJson({ sourceFile: 'standings.xlsx', sheets:[{ name: 'Ladder', //range: 'A1:B4', // header:{ // rows: 0 // }, //'*': '{{columnHeader}}', columnToKey: { A: 'key', B: 'value' } },{ name: 'Ladder', //range: 'A5:C20', // header:{ // rows: 5 // }, columnToKey: { A: 'rank', B: 'team', C: 'total' } //'*': '{{columnHeader}}', }]
Result
{ Ladder: [ { rank: 'Season', team: 'Autumn' }, { rank: 'Year', team: 2021 }, { rank: 'Comp', team: 'Comp1' }, { rank: 'Round', team: 1 }, { rank: 'Ranking', team: 'Team', total: 'Total' }, { rank: 1, team: 'Team1', total: 0 }, { rank: 2, team: 'Team2', total: 0 }, { rank: 3, team: 'Team3', total: 0 }, { rank: 4, team: 'Team4', total: 0 }, { rank: 5, team: 'Team5', total: 0 }, { rank: 6, team: 'Team6', total: 0 }, { rank: 7, team: 'Team7', total: 0 }, { rank: 8, team: 'Team8', total: 0 }, { rank: 9, team: 'Team9', total: 0 } ] }
I thought at a minimum it could output:
{ Ladder: [ { key: 'Season', value: 'Autumn' }, { key: 'Year', value: 2021 }, { key: 'Comp', value: 'Comp1' }, { key: 'Round', value: 1 }, { rank: 'Ranking', team: 'Team', total: 'Total' }, { rank: 1, team: 'Team1', total: 0 }, { rank: 2, team: 'Team2', total: 0 }, { rank: 3, team: 'Team3', total: 0 }, { rank: 4, team: 'Team4', total: 0 }, { rank: 5, team: 'Team5', total: 0 }, { rank: 6, team: 'Team6', total: 0 }, { rank: 7, team: 'Team7', total: 0 }, { rank: 8, team: 'Team8', total: 0 }, { rank: 9, team: 'Team9', total: 0 } ] }
Ideally I would like to specify a region for a sheet and it would give me a different array for each section perhaps I could define a section name
heading: [], ladder[]
I guess the second way is that I would have to have separate excelToJson calls for each section and then merge the results?
excelToJson
Any suggestions would be welcomed?
Hi there,
A great library. I was wondering how I could read various ranges from the same sheet:
At the moment I have the following:
Result
I thought at a minimum it could output:
Ideally I would like to specify a region for a sheet and it would give me a different array for each section perhaps I could define a section name
I guess the second way is that I would have to have separate
excelToJson
calls for each section and then merge the results?Any suggestions would be welcomed?