Excel Sheets, Rows and Tables
xl_structureModify Excel workbook structure by adding or deleting sheets, rows, columns, tables, and named ranges; sort, filter, and validate data while rewriting references and backing up files.
Instructions
Workbook structure: add, rename, delete or hide sheets, insert or delete rows and columns (references are rewritten), tables, named ranges, sort, filters and data validation. Values are xl_edit. Every change backs the file up first; refuses a workbook open in Excel. Ops, one per line, as name(required; opt optional): what it does. path, backup and verify_com are not repeated; xl_help shows them:
manage_worksheet(action; opt sheet new_name index state allow_loss): Add, delete, rename, copy, reorder, hide or unhide a sheet; rename rewrites references to it and delete turns them into #REF!, as Excel does.
modify_grid_structure(action, at; opt count sheet allow_loss): Insert or delete rows or columns and rewrite every reference on every sheet; references inside a deleted band become #REF!.
create_table(location, name; opt header style row_stripes col_stripes totals_row totals sheet allow_loss): Turn a range into an Excel table (ListObject) named name.
manage_table(name, action; opt values index column new_name new_ref style on totals row_stripes col_stripes sheet allow_loss): Add or delete rows and columns, rename, resize, toggle totals, restyle or unlist the table named name (action).
manage_name(action; opt name refers_to scope new_name allow_loss): Add, delete, rename, update or list defined names; an ambiguous name refuses until scope is given.
sort_range(location, keys; opt has_header sheet allow_loss): Sort a range or table body by one or more keys, writing the rows back reordered.
set_filter(location; opt criteria sheet allow_loss): Apply an autofilter and hide the rows that do not meet all criteria; rows with uncalculated formulas stay visible.
clear_filter(opt location sheet allow_loss): Remove the autofilter from a sheet and unhide the rows it hid, the reverse of set_filter. More ops follow, in the same format, in the op parameter's description.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | Yes | The operation to run: an op listed in this tool's description, or one of these, in the same format: - manage_data_validation(action; opt location dv_type values operator formula1 formula2 allow_blank prompt error sheet allow_loss): Add, list or delete data-validation rules (list, whole, decimal, date, time, text_length, custom); Excel enforces them. | |
| args | No | The op's arguments as an object. Include path (the workbook file) unless the op's line names other paths or the op reads no workbook; unknown keys are refused. xl_help lists every argument. |