Your privacy choices

We use cookies and similar technologies. The necessary ones keep the site working. With your permission we would also use others, which you can review in the settings. You can change your mind at any time.

createEmptyWorkbook

fancy-sheets

Workbook factory.

Why
Every spreadsheet app needs an initial state — an empty workbook with one sheet ready for the user to start typing. Without a factory, you'd manually construct the nested object structure (WorkbookData with sheets, SheetData with id, name, empty cells map, column widths, merged regions, filters), scatter that seed-data logic across your app, and risk subtle differences (missing properties, wrong activeSheetId) that cause undefined behavior when cell operations run.
What
createEmptyWorkbook() is a zero-argument factory function that returns a WorkbookData object shaped for the <Spreadsheet> component. It initializes one sheet (id “sheet-1”, name “Sheet 1”) with empty cells, no column overrides, no merged regions, no filters, and that sheet set as active. The returned workbook is JSON-serializable and agent-compatible — all properties are primitives, arrays, and plain objects.
How
Import from @particle-academy/fancy-sheets, call createEmptyWorkbook() with no arguments, and pass the result to <Spreadsheet defaultData={createEmptyWorkbook()}> or use it as the seed value in your state management. For controlled spreadsheets, you can mutate or serialize the returned workbook via data prop and onChange callback.