Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to parse multiple sheets in the same xslx file? #16

Open
rivershertz opened this issue Jan 17, 2023 · 1 comment
Open

How to parse multiple sheets in the same xslx file? #16

rivershertz opened this issue Jan 17, 2023 · 1 comment

Comments

@rivershertz
Copy link

Im using this package to create json files for translations.
The different languages content is separated into multiple sheets in the same file.
Im trying to figure out how can I iterate over the sheets and execute code for each one?

Is it possible?
Thanks a lot!

@pmartinspt
Copy link

Hey!

I am using this to export all the sheets to one unique json file.

Hope it can help!

const fs = require('fs');
var parser = new (require('simple-excel-to-json').XlsParser)();
var doc = parser.parseXls2Json('input-values.xlsx', { isNested: true });

let export_all = [];
let number_of_sheets = 5

for (let i = 0; i < number_of_sheets; i++) {
    export_all.push(doc[i]);  
  }

json=  JSON.stringify(export_all.flat())
fs.writeFile("export-all.json", json, (err) => err && console.error(err));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants