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

Error for some .xlsx files #10

Open
bazaglia opened this issue Feb 7, 2017 · 4 comments
Open

Error for some .xlsx files #10

bazaglia opened this issue Feb 7, 2017 · 4 comments

Comments

@bazaglia
Copy link

bazaglia commented Feb 7, 2017

Although it works for some xlsx files, for other ones I get this error:

/Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:398
  mongoModel.forEach(function(f) {
             ^

TypeError: mongoModel.forEach is not a function
    at convertMongoModelToObject (/Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:398:14)
    at Object.exports.xlsxData2MongoData (/Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:328:24)
    at /Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:305:29
    at /Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/xlsx-rw.js:69:12
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
@bazaglia
Copy link
Author

bazaglia commented Feb 7, 2017

Fixed: it was due to multiple sheets in same file. I've had to split them into separate files.

@bazaglia bazaglia closed this as completed Feb 7, 2017
@acedward
Copy link
Contributor

acedward commented Feb 7, 2017

If a single xlsx is parsed the result has the format [ { row1 } , { row2 } ]
if it has multiple pages the results has the format [[{ s1-row1 } , { s1-row2 }], [{ s2-row1 }, { s2-row2 }] ]

@bazaglia
Copy link
Author

bazaglia commented Feb 7, 2017

@acedward But xlsx2MongoData method fails when a file has multiple pages.

@acedward
Copy link
Contributor

acedward commented Feb 7, 2017

I just created a two-sheet excel file with one data-point per sheet.

const model = null;
const xlsx  = '/Users/eddie/Downloads/multipage-test.xlsx';
mongoxlsx.xlsx2MongoData(xlsx, model, (e, data) => console.log(data));

[ [ { 'sheet-a-header-1': 'a' } ], [ { 'sheet-b-header-1': 'b' } ] ]

multipage-test.xlsx

@acedward acedward reopened this Feb 7, 2017
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