MCP Office Word
v0.7.050-tool Word MCP server.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
get_workbook_context
Return an Artifact Context Packet (ACP) for an Excel workbook. Progressive disclosure via the ``level`` parameter: - **index** — identity + summary only (fast; single stat + openpyxl open) - **focused** — + sheet_names, sheet_count, table_names - **deep** — + metadata_policy, named_ranges (names only), lineage_summary, and optional annotations Security guarantees: - Path must be within EXCEL_ALLOWLIST_ROOTS (allowlist is enforced). - ACPDetail never contains cell values (S-001). - Annotations are validated with validate_acp_annotations() before storage. Returns a…
| Parameter | Type | Description |
|---|---|---|
path * | string | |
annotations | ||
level | string |
bulk_copy_sheet
Copy *source_sheet* to multiple new sheets in a single call. new_names: list of new sheet names to create (no duplicates, max 31 chars each, no /\*?[] chars). insert_after: if provided, new sheets are placed immediately after this sheet. Note: openpyxl copy_worksheet does NOT copy charts, images, or print settings. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
new_names * | array | |
path * | string | |
source_sheet * | string | |
confirm | boolean | |
insert_after |
set_row_heights
Set heights for multiple rows in a single call. Mode 1 (uniform): provide rows or row_range (e.g. '1:20') plus height. Mode 2 (per-row): provide row_specs list of {"row": int, "height": float}. Valid height: 0.0–409.0. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string | |
confirm | boolean | |
height | ||
row_range | ||
row_specs | ||
rows |
set_column_widths
Set widths for multiple columns in a single call. Provide exactly one of columns (list of letters) or col_range (e.g. 'A:E'). Provide exactly one of width (0-255) or autofit=True. autofit approximates width from cell content; max_width caps the result. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string | |
autofit | boolean | |
autofit_padding | number | |
col_range | ||
columns | ||
confirm | boolean | |
max_width | number | |
width |
bulk_add_comments
Add multiple cell comments in one call. Each dict: address, text, author (optional). Returns comments_added count.
| Parameter | Type | Description |
|---|---|---|
comments * | array | |
path * | string | |
sheet * | string | |
confirm | boolean | |
overwrite | boolean |
fill_formula_range
Fill start_address:end_address with formula, auto-relativizing references. Formula must start with '='. Returns filled_cells count. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
end_address * | string | |
formula * | string | |
path * | string | |
sheet * | string | |
start_address * | string | |
confirm | boolean |
bulk_range_write
Write multiple non-contiguous cells in a single tool call. Writes a list of cell updates to the same sheet in one open/save cycle — more efficient than calling ``range_io`` or ``cell`` once per cell.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the workbook. Must be within EXCEL_ALLOWLIST_ROOTS. |
sheet * | string | Sheet name. |
writes * | array | Each item: ``{"address": "A1", "value": <scalar>}``. Strings starting with ``=``, ``+``, ``-``, or ``@`` are rejected (formula injection guard). |
confirm | boolean | Must be True to authorise the write. Requires ``EXCEL_ENABLE_WRITE=true``. |
chart
Manage Excel charts: create, list, delete, or update. operation='list': returns {"charts": [...], "count": N} — no confirm needed. operation='create': chart_type and data_address required. confirm=True required. chart_type: bar, line, scatter, pie. data_address: e.g. 'A1:B5' (include headers). target_address: cell where chart is placed (default 'D1'). width_px / height_px: chart size in pixels (1–5000). operation='delete': chart_index (0-based) required. confirm=True required. operation='update': chart_index and data_address required. confirm=True required. Write operations requir…
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
anchor | ||
chart_index | ||
chart_type | ||
confirm | boolean | |
data_address | ||
height_px | ||
target_address | ||
title | string | |
width_px |
export_as_pdf
Export a worksheet or entire workbook to PDF via Excel COM. scope='sheet' exports a single named worksheet (sheet param required). scope='workbook' exports all visible sheets in print order. The source workbook is opened read-only and is not modified.
| Parameter | Type | Description |
|---|---|---|
output_path * | string | Absolute path for the output PDF file. Must be within EXCEL_EXPORT_ROOTS and end in .pdf. |
path * | string | Absolute path to the source .xlsx/.xlsm workbook. Must be within EXCEL_ALLOWLIST_ROOTS. |
scope * | string | 'sheet' to export one worksheet; 'workbook' to export all visible sheets. |
confirm | boolean | Must be True. |
quality | integer | 0 = standard quality (default), 1 = minimum quality. |
sheet | Worksheet name (required when scope='sheet'; must be omitted when scope='workbook'). |
export_range_as_csv
Export a cell range as CSV. live=False (default): reads cached values via openpyxl -- no COM, CI-safe. live=True: reads live-evaluated values via Excel COM (Windows only, requires EXCEL_ENABLE_COM=true). output_path + any mode: write CSV to file (needs EXCEL_CSV_EXPORT_ROOTS + EXCEL_ENABLE_WRITE=true + confirm=True).
| Parameter | Type | Description |
|---|---|---|
address * | string | Cell range in A1 notation, e.g. "A1:C10". |
path * | string | Workbook path within EXCEL_ALLOWLIST_ROOTS. |
sheet * | string | Worksheet name. |
confirm | boolean | Required (True) when output_path is provided. |
delimiter | string | CSV delimiter character. One of: , \t ; | (default: ,). |
include_headers | boolean | If True (default), all rows are written to CSV. If False, the first row (header) is skipped. |
live | boolean | If True, use Excel COM to read live calculated values. |
output_path | If provided, write CSV to this .csv file. |
recalculate_workbook
Force recalculation of all formulas in a workbook using Excel COM. Opens the workbook in Excel, triggers recalculation, saves in-place, and closes. The source workbook is modified (formulas are evaluated and their cached values updated in the file).
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the .xlsx or .xlsm workbook. Must be within EXCEL_ALLOWLIST_ROOTS. |
confirm | boolean | Must be True. Required because this operation saves the source workbook in-place (permanent mutation). |
full_calc | boolean | If True, calls Application.CalculateFull() which rebuilds the entire dependency tree across all open workbooks. If False (default), calls wb.Calculate() which recalculates only di… |
hydrate_template
Open a workbook template, write cell values, and save as a new file. Writes data to named ranges or cell addresses in the template workbook and saves the result to output_path. The template is not modified (SaveAs creates a new file at output_path). cell_writes format (list of dicts with 'ref' and 'value' keys):: [ {"ref": "A1", "value": "scalar"}, {"ref": "A1:C2", "value": [[1, 2, 3], [4, 5, 6]]}, {"ref": "named_range", "value": "ProjectX"}, {"ref": "Sheet2!B3", "value": 42.0}, ]
| Parameter | Type | Description |
|---|---|---|
template_path * | string | Absolute path to source .xlsx/.xlsm template. |
cell_writes | List of {ref, value} write instructions. | |
confirm | boolean | Must be True. |
output_path | string | Absolute path for output .xlsx/.xlsm file. |
recalculate | boolean | If True (default), calls Application.CalculateFull() before SaveAs. |
sheet | Optional default sheet for Range() lookups. |
pivot_table
Create, read, or refresh Excel pivot tables via Excel COM. operation='create': Build a new pivot table from a local worksheet range. operation='read': Return structure and data of a named pivot table. operation='refresh': Refresh all pivot caches (xlDatabase sources only).
| Parameter | Type | Description |
|---|---|---|
operation * | string | 'create', 'read', or 'refresh'. |
path * | string | Absolute path to .xlsx/.xlsm workbook. |
col_fields | Field names for the column axis (create only). | |
confirm | boolean | Must be True for create and refresh operations. |
dest_address | Upper-left cell for pivot e.g. 'F1' (create only). | |
dest_sheet | Existing sheet for pivot output (create only). | |
pivot_name | PivotTable name to read (read only). | |
row_fields | Field names for the row axis (create only). | |
sheet | Worksheet name (read: required; refresh: optional filter). | |
source_address | Sheet-qualified range e.g. 'Sheet1!A1:D100' (create only). | |
table_name | string | PivotTable name (create only; default 'PivotTable1'). |
value_fields | Field names to aggregate (create only). |
get_active_workbook_context
Return name, path, and sheet list for the workbook active in Excel. Requires EXCEL_ENABLE_COM=true. Returns only workbooks within EXCEL_ALLOWLIST_ROOTS; workbooks outside the allowlist are treated as unavailable (status: outside_allowlist).
get_all_open_workbooks
List all workbooks open in the running Excel instance. Requires EXCEL_ENABLE_COM=true. Filters to EXCEL_ALLOWLIST_ROOTS only; workbooks outside the allowlist are silently excluded (their paths and names are not exposed — not even as a count or redacted entry).
list_macros
List all VBA components in a workbook via the VBA project object model. Enumerates VBProject.VBComponents and returns component names and types. Only .xlsm files have a VBA project; passing an .xlsx path raises ValidationError immediately.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to .xlsm workbook. Must be within EXCEL_ALLOWLIST_ROOTS. |
run_macro
Execute a VBA macro in an .xlsm workbook via Excel COM.
| Parameter | Type | Description |
|---|---|---|
macro_name * | string | VBA Sub or Function name. Valid formats: "MyMacro" or "Module1.MyMacro". Must match ^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$ . |
path * | string | Absolute path to .xlsm workbook. Must be within EXCEL_ALLOWLIST_ROOTS. |
args | Optional list of positional arguments to pass to the macro. | |
confirm | boolean | Must be True (write gate). |
apply_number_format
Apply a number format code (e.g. '#,##0.00', 'YYYY-MM-DD') to a cell or range. Does NOT auto-save. Call save() to persist changes to disk. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
format_code * | string | |
path * | string | |
sheet * | string | |
confirm | boolean |
apply_style
Apply styling to one or more cell ranges. address: single range string (e.g. 'A1:B2') — preferred. ranges: list of range strings — still supported for backward compat. Provide address OR ranges, not both. font_color and bg_color must be 6 hex digits without '#', e.g. 'FF0000'. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string | |
address | ||
bg_color | ||
bold | ||
confirm | boolean | |
font_color | ||
font_size | ||
italic | ||
ranges |
apply_alignment
Apply alignment to a cell or range. *horizontal*: left, center, right, fill, justify. *vertical*: top, center, bottom. Does NOT auto-save. Call save() to persist changes to disk. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
horizontal | ||
vertical | ||
wrap_text |
add_border
Apply a border to all sides of a cell or range. *border_style*: thin, medium, thick, dashed, dotted, double. *color*: 6 hex digits without '#', e.g. '000000'. Does NOT auto-save. Call save() to persist changes to disk. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
path * | string | |
sheet * | string | |
border_style | string | |
color | string | |
confirm | boolean |
apply_format_to_sheet_list
Apply formatting to the same address across multiple sheets. sheets=None applies to all non-underscore-prefixed sheets (_Lists etc skipped). Explicit sheet list overrides the skip guard. style keys: bold, italic, font_size, font_color, bg_color. alignment keys: horizontal, vertical, wrap_text. column_widths: {"A": 15, "B:D": 12} — sets column widths on every target sheet. row_heights: {"1": 25, "2:10": 18} — sets row heights on every target sheet. EXCEL_MAX_RANGE_CELLS is enforced per sheet. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
address | ||
alignment | ||
column_widths | ||
confirm | boolean | |
number_format | ||
row_heights | ||
sheets | ||
style |
copy_range_format
Copy formatting only (no values) from src to dst range. Cross-sheet. dst can be single cell (auto-expands). Copies: font, fill, number_format, alignment. Border only if copy_border=True. Does NOT copy: values, formulas, comments, hyperlinks. MergedCell slave cells in src are skipped silently. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
dst_address * | string | |
dst_sheet * | string | |
path * | string | |
src_address * | string | |
src_sheet * | string | |
confirm | boolean | |
copy_border | boolean |
write_range_with_format
Write a 2-D array of values to a range and apply consistent formatting in one call.
| Parameter | Type | Description |
|---|---|---|
address * | string | Top-left cell or full range address (e.g. "B2" or "B2:E10"). |
data * | array | 2-D list (rows x columns) of values to write. |
path * | string | Absolute path to the .xlsx workbook. |
sheet * | string | Worksheet name. |
alignment | Optional alignment dict. Allowed keys: horizontal, vertical, wrap_text, shrink_to_fit, text_rotation, indent. | |
confirm | boolean | Must be True to execute the write. |
number_format | Optional Excel number format string (e.g. "#,##0.00"). | |
style | Optional style dict. Allowed keys: bold, italic, underline, font_color, bg_color, font_size, font_name. |
apply_conditional_format
Apply a conditional-formatting rule to a range.
| Parameter | Type | Description |
|---|---|---|
address * | string | Cell range to apply CF to (e.g. "A1:Z100"). |
condition * | string | For cell_is: "<operator> <value>" e.g. "greaterThan 100", "between 10 20". Operator choices: greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, equal, notEqual, between, notBetw… |
format_spec * | object | Formatting to apply when rule fires. Allowed keys: bold, italic, font_color, bg_color, number_format (number_format silently ignored). |
path * | string | Absolute path to the .xlsx workbook. |
rule_type * | string | "cell_is" (compare cell value) or "formula" (arbitrary formula). |
sheet * | string | Worksheet name. |
confirm | boolean | Must be True to execute the write. |
formula | Required when rule_type="formula". Must start with "=". |
format
Unified format dispatcher — routes 8 format operations through a single tool. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``. operation vocabulary -------------------- "number_format" Apply a number-format code to a cell or range. Params: path, sheet, address, format_code, confirm. "style" Apply font/fill styling to one or more ranges. Params: path, sheet, address (or ranges), bold, italic, font_size, font_color, bg_color, confirm. "alignment" Apply horizontal/vertical/wrap_text alignment.…
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
address | ||
alignment | ||
bg_color | ||
bold | ||
border_style | string | |
color | string | |
column_widths | ||
condition | ||
confirm | boolean | |
copy_border | boolean | |
data | ||
dst_address | ||
dst_sheet | ||
font_color | ||
font_size | ||
format_code | ||
format_spec | ||
formula | ||
horizontal | ||
italic | ||
number_format | ||
ranges | ||
row_heights | ||
rule_type | ||
sheet | ||
sheets | ||
src_address | ||
src_sheet | ||
style | ||
vertical | ||
wrap_text |
get_used_range
Return the bounding box of used cells in *sheet* of the workbook at *path*.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string |
cell
Read or write a single cell value. operation='read': returns cell value, type, and formula (read-only). operation='write': writes value to the cell. Requires EXCEL_ENABLE_WRITE=true and confirm=True. value=None is not allowed for 'write' (use range_io with values=[[None]] to clear a cell).
| Parameter | Type | Description |
|---|---|---|
address * | string | |
operation * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
value |
range_io
Read or write a rectangular range of cells. operation='read': returns {"data": [[{...},...], ...], "rows": int, "cols": int}. operation='write': writes values 2-D array starting from address cell. Requires EXCEL_ENABLE_WRITE=true and confirm=True for 'write'.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
operation * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
values |
read_sheet_all
Read the entire used range of *sheet* from the workbook at *path*. Returns all cell data, row count, and column count. Subject to EXCEL_MAX_RANGE_CELLS guard.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string |
get_cell_metadata
Return formatting and metadata for a single cell. Includes font, fill, number format, comment, and hyperlink information. *address* must be in A1 notation (e.g. "B3").
| Parameter | Type | Description |
|---|---|---|
address * | string | |
path * | string | |
sheet * | string |
consolidate_ranges
Read multiple ranges from workbooks and merge into one table. Each entry in ``ranges`` must have keys: ``path``, ``sheet``, ``range``, and optionally ``label``. Enforces EXCEL_ALLOWLIST_ROOTS via wb.read_range (BLOCKER-2 compliance -- no direct openpyxl.load_workbook calls here). Does NOT require EXCEL_ENABLE_WRITE. Does NOT require confirm.
| Parameter | Type | Description |
|---|---|---|
ranges * | array | |
max_rows | integer | |
source_label_key | string |
sheet
Manage workbook sheets: list, add, rename, or delete. operation='list': returns {"sheets": [str, ...], "count": int} — no confirm needed. operation='add': adds a new sheet named sheet_name at optional position. operation='rename': renames sheet_name to new_name. operation='delete': deletes sheet named sheet_name. Write operations require EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
confirm | boolean | |
new_name | ||
position | ||
sheet_name |
list_tables
List all Excel tables (ListObjects) in *sheet*, or across all sheets when *sheet* is omitted. Each entry contains sheet, name, display_name, ref, header_row, and totals_row. Omitting *sheet* enables workbook-wide table discovery.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet |
read_table
Read all rows from a named Excel table in *sheet*. Returns table metadata, headers, and all data rows.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string | |
table_name * | string |
append_rows
Append *rows* after the last used row in *sheet*. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
rows * | array | |
sheet * | string | |
confirm | boolean |
find_replace
Find and replace string values across all cells in *sheet*. Set ``whole_cell=False`` for substring replacement. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
find_value * | string | |
path * | string | |
replace_value * | string | |
sheet * | string | |
confirm | boolean | |
match_case | boolean | |
whole_cell | boolean |
import_csv_to_sheet
Import a CSV or TSV file into *sheet*. All rows including the header row are imported by default so column names are preserved. Set ``skip_header=True`` to discard the first row. Set ``overwrite=True`` to replace an existing sheet with the same name. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
csv_path * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
overwrite | boolean | |
skip_header | boolean |
named_range
List, read, or write Excel named ranges (defined names). operation='list': returns {"named_ranges": [{name, refers_to, scope}, ...], "count": N}. operation='read': reads the data values at the named range. name is required. operation='write': creates or updates a named range. name, sheet, address, confirm all required. 'write' requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
address | ||
confirm | boolean | |
name | ||
sheet |
create_workbook
Create a new .xlsx workbook at the specified path. sheets: worksheet names to create (default: ["Sheet1"]). overwrite: if False (default), raises ExcelMCPError if the file exists. confirm: must be True (write gate — prevents accidental creation). Returns: {"ok": true, "path": "...", "sheets": [...], "created": true}
| Parameter | Type | Description |
|---|---|---|
path * | string | |
confirm | boolean | |
overwrite | boolean | |
sheets |
save
Flush the in-memory workbook at *path* to disk. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``. Evicts the workbook from the cache after saving.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
confirm | boolean |
workbook_metadata
Read or write workbook-level metadata stored on a hidden worksheet. operation='read': returns whether metadata is present plus stored payload details. operation='write': stores payload on hidden sheet _MCP_META. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
confirm | boolean | |
payload |
evaluate_formula
Return the formula string and value for *address*. When live=False (default): openpyxl returns the last-saved cached value. When live=True: opens workbook via Excel COM for live evaluation. Useful for volatile functions (TODAY, NOW, RAND, OFFSET). Requires EXCEL_ENABLE_COM=true when live=True.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
path * | string | |
sheet * | string | |
live | boolean |
capabilities
Return metadata about this MCP phase and its available tools.
merge
Manage merged cell ranges in a worksheet. operation='list': returns {"sheet": str, "merged_ranges": [str, ...], "count": int}. operation='merge': merges the address range. Requires EXCEL_ENABLE_WRITE=true and confirm=True. operation='unmerge': unmerges the address range. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
address | ||
confirm | boolean |
freeze_panes
Freeze rows/columns at a cell; pass address=None to unfreeze. Requires confirm=True and EXCEL_ENABLE_WRITE.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
sheet * | string | |
address | ||
confirm | boolean |
auto_filter
Apply Excel AutoFilter to a range; pass address=None to clear. Requires confirm=True and EXCEL_ENABLE_WRITE.
| Parameter | Type | Description |
|---|---|---|
address * | ||
path * | string | |
sheet * | string | |
confirm | boolean |
rows
Insert or delete rows in a worksheet. operation='insert': inserts `count` blank rows before `start_row`. operation='delete': deletes rows from `start_row` to `end_row` (inclusive; end_row defaults to start_row). Both require EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
start_row * | integer | |
confirm | boolean | |
count | integer | |
end_row |
cols
Insert or delete columns in a worksheet. operation='insert': inserts `count` blank columns before `start_col` (1-based). operation='delete': deletes columns from `start_col` to `end_col` (inclusive; end_col defaults to start_col). Both require EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
start_col * | integer | |
confirm | boolean | |
count | integer | |
end_col |
protect
Protect or unprotect a sheet or the entire workbook structure. scope='sheet': protects/unprotects the named sheet. password=None clears protection. scope='workbook': protects/unprotects workbook structure. password=None clears protection. Both require EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
scope * | string | |
confirm | boolean | |
lock_structure | boolean | |
lock_windows | boolean | |
password | ||
sheet |
set_print_area
Set or clear the print area for a worksheet. Pass address=None to clear the print area. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
address * | ||
path * | string | |
sheet * | string | |
confirm | boolean |
cell_comment
Get or delete a cell comment. operation='get': returns comment text and author (read-only, no confirm needed). operation='delete': removes the comment. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
operation * | string | |
path * | string | |
sheet * | string | |
confirm | boolean |
sheet_properties
Get or set sheet display properties. operation='get': returns tab_color, state, show_gridlines, show_row_col_headers, zoom_scale. operation='set': updates one or more properties. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
show_gridlines | ||
show_row_col_headers | ||
state | ||
tab_color | ||
zoom_scale |
data_validation
Get or add data validation rules in a worksheet. operation='get': returns all validation rules for the sheet. operation='add': adds validation rules from the validations list. Each item must have 'address' key. Requires EXCEL_ENABLE_WRITE=true and confirm=True for 'add'.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
validations |
validate_formula_syntax
Check whether a formula string is syntactically valid for Excel without writing it.
| Parameter | Type | Description |
|---|---|---|
formula | string | |
path | string |
copy_range
Copy cells (values and formats) from src_address to dst_address within the same sheet. Requires EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
dst_address * | string | |
path * | string | |
sheet * | string | |
src_address * | string | |
confirm | boolean |
create_table
Create a native Excel table (ListObject) over the specified range in a worksheet. address: cell range for the table (e.g. 'A1:D20'). style: Excel table style name (default 'TableStyleMedium9'). Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
address * | string | |
path * | string | |
sheet * | string | |
confirm | boolean | |
style | string | |
table_name |
set_column_visibility
Hide or show one or more columns. columns: list of column letters, e.g. ['A', 'C', 'D']. hidden: True to hide, False to show. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
columns * | array | |
hidden * | boolean | |
path * | string | |
sheet * | string | |
confirm | boolean |
set_workbook_calc_mode
Set workbook calculation mode and/or fullCalcOnLoad flag. calc_mode: one of 'auto', 'manual', 'autoNoTable'. None = no change. full_calc_on_load: if True, Excel recalculates all formulas on next open. Requires ``EXCEL_ENABLE_WRITE=true`` and ``confirm=True``.
| Parameter | Type | Description |
|---|---|---|
path * | string | |
calc_mode | ||
confirm | boolean | |
full_calc_on_load |
hyperlink
Manage hyperlinks in a worksheet. operation='get': returns all hyperlinks (read-only). operation='add': adds hyperlinks from the links list. Validates URL schemes — javascript:, data:, vbscript: are always blocked (OWASP A03). operation='remove': removes hyperlink from address. Requires confirm=True. Write operations require EXCEL_ENABLE_WRITE=true and confirm=True.
| Parameter | Type | Description |
|---|---|---|
operation * | string | |
path * | string | |
sheet * | string | |
address | ||
apply_style | boolean | |
confirm | boolean | |
links |
review_workbook_render
Review an Excel workbook's render quality before/after PDF export. Runs structural checks (PRINT_AREA_UNSET, SHEET_EMPTY, FORMULA_STALE, PRINT_AREA_EXCEEDS_PAGE) on the specified sheets and returns findings. Read-only — does NOT modify the workbook.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to the .xlsx workbook. |
recalculated | boolean | Set True if recalculate_workbook() was called before export. Suppresses FORMULA_STALE finding. |
sheet_names | Sheet names to review. None → all non-chart sheets. |
produce_export_evidence_bundle
Produce a structured evidence bundle aggregating PDF export + review findings. Call after review_workbook_render and export_as_pdf to close the render-check-iterate loop.
| Parameter | Type | Description |
|---|---|---|
export_results * | array | List of export result dicts from export_as_pdf calls. Must be a list — raises ToolError if not. Each entry must contain at least 'sha256' and 'exported_at'. |
path * | string | Absolute path to the workbook. |
review_results * | array | List of review result dicts from review_workbook_render. Must be a list — raises ToolError if not. |
exports_dir | Optional directory containing the exported PDF(s). |
export_changed_sheets_only
Re-export only sheets whose content has changed since the last export run. Uses openpyxl cell-value hashing to detect mutations. Exports changed sheets via export_as_pdf. Returns hashes for ALL sheets so the caller can store them for the next iteration. Requires EXCEL_ENABLE_WRITE=true. If EXCEL_ENABLE_COM is not true, falls back to hash-only mode (no PDF export). confirm=True is always required.
| Parameter | Type | Description |
|---|---|---|
base_dir * | string | Directory where per-run export subdirectories are created. |
path * | string | Absolute path to the .xlsx workbook. |
previous_hashes * | object | Dict mapping sheet_name → sha256 hash string from the previous run. Pass {} for the first run (all sheets are treated as changed). |
confirm | boolean | Must be True to proceed (mutation guard). |
snapshot_workbook
Copy a workbook to a timestamped snapshot file. Creates a point-in-time copy of the workbook without opening it in Excel or openpyxl (shutil.copy2 preserves metadata). The snapshot filename defaults to <original_stem>_<YYYYMMDD_HHMMSS><original_suffix>.
| Parameter | Type | Description |
|---|---|---|
path * | string | Absolute path to source .xlsx/.xlsm workbook. Must be within EXCEL_ALLOWLIST_ROOTS. |
confirm | boolean | Must be True (write gate). |
dest_dir | Directory to write the snapshot into. Must be within EXCEL_ALLOWLIST_ROOTS. If None, uses source file's parent directory. | |
filename | Override the auto-generated snapshot filename. If provided, must end in .xlsx or .xlsm. If None, auto-generates: <stem>_<YYYYMMDD_HHMMSS><suffix>. |
diff_workbooks
Compare two workbooks cell-by-cell and return differences. Loads both workbooks with openpyxl (data_only=True) and compares the values of matching sheets. Only sheets present in BOTH workbooks are compared (unless sheets is specified).
| Parameter | Type | Description |
|---|---|---|
path_a * | string | Absolute path to first workbook (baseline). Must be within EXCEL_ALLOWLIST_ROOTS. |
path_b * | string | Absolute path to second workbook (comparison). Must be within EXCEL_ALLOWLIST_ROOTS. |
max_diffs | integer | Maximum total differences to return (default 200). Truncates result set with truncated=True flag. |
sheets | Optional list of sheet names to compare. If None, compares sheets present in both workbooks. |