Context
- NodeJS 10
- ExcelJS 0.8.5
- LibreOffice 5.1.6.2 on Ubuntu
Issue
I am trying to create a multi-sheet Excel file with ExcelJS.
I am following the official documentation from the ExcelJS github page.
The first step is the creation of the workbook. In my case, i want a stream because i will append lot of datas.
// Create Excel Workbook Stream
const workbookStream = new Excel.stream.xlsx.WorkbookWriter({
filename: path,
useStyles: true,
useSharedStrings: true,
});
Then i add sheet to the created workbook's stream as said into the documentation Worksheet Properties.
const sheet = workbookStream.addSheet('sheet1'); // Throw here
But in this way, i got the following error :
'Type error: workbookStream.addSheet is not a function
I have also found a code that do not throw but do not work and do not create many sheets.
const header = ['A', 'B', 'C'];
const sheet1 = Excel.addSheetOnWorkbook({
workbook: workbookStream,
name: 'sheet1',
});
const sheet2 = Excel.addSheetOnWorkbook({
workbook: workbookStream,
name: 'sheet2',
});
sheet.addRow(header).commit();
sheet.addRow(header).commit();
await workbookStream.commit();
In this case, only the sheet1 is created (opening with LibreOffice 5.1.6.2).
Any way to resolve this case with ExcelJS ?