Skip to content

API reference / Common / Engine types / WorkbookCommand

Type Alias: WorkbookCommand ​

ts
type WorkbookCommand = 
  | {
  insertWorksheet: {
     index: number;
     name?: string;
  };
}
  | {
  deleteSheets: {
     ids: SheetId[];
  };
}
  | {
  reorderSheets: {
     ids: SheetId[];
     to: number;
  };
}
  | {
  renameSheet: {
     id: SheetId;
     name: string;
  };
}
  | {
  setSheetsState: {
     ids: SheetId[];
     state: SheetState;
  };
}
  | {
  setSheetsTabColor: {
     ids: SheetId[];
     color: GridColor | null;
  };
};

An edit intent on the workbook's sheets — the sheet tab's commands, the twin of presentation's SlideCommand. Sheets are addressed by id; ids the workbook's sheet list doesn't hold are skipped. Each command commits once, so the whole command is one undo step — a delete's included, which Excel can't undo.

A command Excel refuses is refused with an InvalidRequest error saying why, and nothing written: a name Excel takes for no sheet, and a delete or a hide that would leave no sheet visible.