Skip to content

ViewManager

Manages a workbook’s collection of views. Access via workbook.views.

A view holds the active-sheet pointer and per-sheet selection / layout / zoom state. Most workbooks have exactly one view (get(0)); the multi-view model exists to support OOXML’s bookViews collection.

Use get or require to obtain a WorkbookView bound to a specific index, then call methods on it to read or write per-sheet state.

const view = workbook.views.require();
view.setActiveSheetName('Summary');
view.setSelection('Summary', { activeCell: 'B2' });
add(): WorkbookView;

Adds a workbook view and returns it.

WorkbookView


get(index?): WorkbookView | null;

Returns the WorkbookView at the given index, or null if it does not exist.

number = 0

Zero-based view index. Defaults to 0 (the only view in typical single-view workbooks).

WorkbookView | null


getAll(): WorkbookView[];

Returns all workbook views as plain JSF view objects (defensive copies), not WorkbookView instances. To operate on a view, use get / require instead.

WorkbookView[]


remove(index): void;

Removes the workbook view at the given index. Cascades to remove matching sheet views from all sheets and decrements the workbookView index on sheet views that referenced a higher index. No-op if the index is out of range or negative.

number

void


require(index?): WorkbookView;

Like get, but throws if the workbook view does not exist.

number = 0

Zero-based view index. Defaults to 0.

WorkbookView