Manage Worksheet
manage_worksheetManage worksheet lifecycle in Excel workbooks: add, delete, rename, copy, reorder, hide, or unhide sheets with auto-backup and safety guards against data loss and reference breakage.
Instructions
Manage the worksheet lifecycle. action is one of: add (new_name, optional index), delete (sheet), rename (sheet, new_name), copy (sheet, optional new_name), reorder (sheet, index as 0-based target), hide (sheet, state 'hidden' or 'very_hidden'), unhide (sheet). The workbook always keeps at least one VISIBLE sheet, so deleting or hiding the last visible one refuses.
Consequence worth knowing: delete does NOT rewrite references, so formulas and defined names that pointed at the deleted sheet break to #REF! when Excel opens the file (Excel's own behavior); rename likewise does not rewrite cross-sheet formula text. Audit references first when in doubt. A hazardous workbook refuses unless allow_loss is true. Auto-backup: prev/anchor slots in .ks4xl-backups (backup=false skips rotation); atomic verified save, restored on failed verify. Refuses while open in Excel.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| index | No | ||
| sheet | No | ||
| state | No | ||
| action | Yes | ||
| backup | No | ||
| new_name | No | ||
| allow_loss | No | ||
| verify_com | No |