Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

promiseObj.wb.WorkSheet is not a function #156

Closed
dangear opened this issue Dec 13, 2017 · 7 comments
Closed

promiseObj.wb.WorkSheet is not a function #156

dangear opened this issue Dec 13, 2017 · 7 comments
Labels

Comments

@dangear
Copy link

dangear commented Dec 13, 2017

Have this error when need to save xls file

TypeError: promiseObj.wb.WorkSheet is not a function
    at /home/dangear/test/xls/node_modules/excel4node/distribution/lib/workbook/builder.js:410:27
    at new Promise (<anonymous>)
    at Object.writeToBuffer (/home/dangear/test/xls/node_modules/excel4node/distribution/lib/workbook/builder.js:402:12)
    at Workbook.write (/home/dangear/test/xls/node_modules/excel4node/distribution/lib/workbook/workbook.js:170:21)
    at readXSL (/home/dangear/test/xls/xls.js:312:5)
    at WriteStream.<anonymous> (/home/dangear/test/xls/xls.js:156:6)
    at WriteStream.emit (events.js:164:20)
    at finishMaybe (_stream_writable.js:616:14)
    at afterWrite (_stream_writable.js:467:3)
    at onwrite (_stream_writable.js:457:7)
...
wb.write('ExcelOut.xlsx', function (err, stats) {
  if (err) {
    console.error(err);
  } else {
    console.log('Done!');
  }
});
...

Node version is 9.3.0

@dangear dangear closed this as completed Dec 13, 2017
@FlyingPumba
Copy link

@dangear I'm having the same problem. Did you manage to solve it ?

@natergj
Copy link
Owner

natergj commented Jul 10, 2018

@FlyingPumba, could you provide a small gist that I can use to try to replicate this issue?

@dangear
Copy link
Author

dangear commented Jul 10, 2018

@FlyingPumba Can you show your code?

@FlyingPumba
Copy link

@natergj @dangear Sorry, I don't have a small gist of code to replicate the issue.

Nevertheless, I think I found the cause of the issue. The problem seems to appear on line https://github.com/natergj/excel4node/blob/master/source/lib/workbook/builder.js#L500 this happens when I call workbook.write(...) with a workbook that doesn't have sheets.

You probably meant to write "promiseObj.wb.Worksheet();" instead of "promiseObj.wb.WorkSheet();".
(There is no object WorkSheet in workbook.js: https://github.com/natergj/excel4node/blob/master/source/lib/workbook/workbook.js)

@natergj natergj reopened this Jul 11, 2018
@natergj
Copy link
Owner

natergj commented Jul 11, 2018

Thanks for finding that @FlyingPumba! I'll get that fixed in the next release

@natergj natergj added the bug label Jul 11, 2018
@natergj
Copy link
Owner

natergj commented Jul 22, 2018

This is now fixed with version 1.5.0

@natergj natergj closed this as completed Jul 22, 2018
@lenhnv1305
Copy link

It seems i meet this error also, my case wb required at least one worksheet, calling wb.addWorksheet(sheetName)

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

No branches or pull requests

4 participants