Excel Workbook Files
xl_workbookCreate, copy, back up, protect, lay out, and export whole Excel workbooks to CSV/TSV/JSON while preserving document properties and avoiding overwrites of the workbook or backups.
Instructions
Whole files: create, copy, backups, document properties, protection, page layout, headers and footers, and export of a range or sheets to CSV, TSV or JSON. Exports never overwrite the workbook or its backups. Edits inside a sheet belong to the other tools; manage_backups lists, restores and snapshots the automatic backups. Ops, one per line, as name(required; opt optional): what it does. path, backup and verify_com are not repeated; xl_help shows them:
create_workbook(opt sheets overwrite): Create a new .xlsx workbook at path with the given sheet names (default a single 'Sheet1').
copy_workbook(src, dst; opt overwrite): Copy a workbook byte for byte from src to dst; an existing dst is replaced only with overwrite=true, after a backup.
manage_backups(action; opt path directory source scope dry_run label dest_dir): List, restore, purge or snapshot the automatic backups (prev and anchor slots, and the copies deletes and clears keep); purge is a dry run unless dry_run=false.
set_workbook_properties(opt title author subject keywords category comments calc_mode full_calc_on_load iterative_calc max_iterations max_change allow_loss): Set document properties and calculation settings (mode, full calc on load, iteration); with none it reports them.
set_protection(action; opt sheet password options unlock_ranges locked structure windows scope allow_loss): Protect or unprotect sheets and workbook structure; advisory only, not encryption (xl_app com_save_with_password encrypts).
set_page_layout(opt sheet orientation paper_size margins scale fit_to_width fit_to_height print_area print_title_rows print_title_cols gridlines headings allow_loss): Set print settings: orientation, paper size, margins, scale or fit, print area and repeated titles; unset values stay.
set_header_footer(opt sheet header footer apply_to raw allow_loss): Write the three-section page headers and footers. 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: - export_range(opt location sheet fmt header values records out_file overwrite bom): Export a range, table or sheet to CSV, TSV or JSON, inline or to a file; values='displayed' writes what the cells show. - export_file(opt fmt sheets out_dir out_file header values records overwrite bom): Export whole sheets to CSV or TSV files, one per sheet, or to one JSON bundle. | |
| 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. |