Creating a workbook can be done one of two ways, depending on how you include the EB project.
import { createWorkbook } from 'excel-builder-vanilla';
const workbook = createWorkbook();import { Workbook } from 'excel-builder-vanilla';
const workbook = new Workbook();This will eventually require you to include the 'excel-builder' module so you can export the workbook, so it's more verbose. However, this is also the best option for creating templates and the like.
Workbooks with no worksheet (i.e. data) will build, but Excel will throw an error while attempting to open it.
You can use excel-builder-vanilla in NodeJS to generate and save Excel files directly to disk:
import fs from 'node:fs';
import { createWorkbook, createExcelFile } from 'excel-builder-vanilla';
const workbook = createWorkbook();
// ... add worksheets and data
const buffer = createExcelFile(workbook);
fs.writeFileSync('output.xlsx', buffer);Note: a Node script can be found in the packages/demo/node-examples/ folder.