natergj / excel4node

Node module to allow for easy Excel file creation
MIT License
1.38k stars 215 forks source link

TypeError: wb.Worksheet is not a function #299

Open maksymstudy opened 4 years ago

maksymstudy commented 4 years ago

Describe the bug When new workbook is created without sheets inside, it can't be written;

wb.write("test.xlsx", function(err, stats) {
        if (err) {
            console.error(err);
        } else {
            console.log(stats); // Prints out an instance of a node.js fs.Stats object
        }
    });

https://github.com/natergj/excel4node/blob/f359412b3d3769ce338f00dfab75c5f80b9f6336/source/lib/workbook/builder.js#L584

It is failed on this line. When I replaced it with promiseObj.wb.addWorksheet();, it worked just fine.

To Reproduce Just create the new workbook without sheets inside.

Expected behavior If wb.sheets.length === 0, create first sheet with .addWorksheet method.

Environment (please complete the following information):