Excel Formatting and Objects
xl_formatApply and manage Excel cell and sheet formatting, including number formats, fonts, fills, borders, styles, merges, conditional formats, comments, hyperlinks, images, charts, dimensions, and views.
Instructions
How cells look and what sits on the sheet: number formats, fonts, fills, borders, named styles, the format painter, column widths and row heights, merges, conditional formats, comments, hyperlinks, images, charts and sheet view. 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:
format_cells(location; opt number_format font fill border alignment sheet allow_loss): Apply formatting to a range, merging onto the existing style so unspecified attributes are preserved.
apply_style(style; opt location define sheet allow_loss): Apply a NAMED cell style to a range, optionally defining it first.
copy_format(source, dest; opt sheet allow_loss): Copy one cell's complete format onto every cell of a destination range, leaving values untouched.
set_dimensions(opt sheet column_widths row_heights autofit_columns hide_columns hide_rows group_rows group_columns ungroup_rows ungroup_columns outline_summary allow_loss): Set column widths and row heights, hide or group rows and columns; autofit here is an estimate (xl_app com_autofit is exact).
set_merge(action; opt location sheet confirm_data_loss allow_loss): Merge or unmerge cell ranges, or list every merge.
manage_conditional_format(action; opt location cf_type params sheet index allow_loss): Add, list or delete conditional-formatting rules (cell_is, formula, color scales, data bars, icon sets and more).
manage_comment(action; opt location text author sheet allow_loss): Add, edit, delete or list cell notes; list also reads threaded comments. Leave author out to sign with the user's own name, or pass author="assistant" to sign as "AI Assistant via KS4XL". 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_hyperlink(action; opt location target display tooltip sheet allow_loss): Add, remove or list cell hyperlinks (a URL or an in-workbook reference); remove keeps the cell's text. - manage_image(action; opt image_file location sheet width height index out_dir allow_loss): Insert, list, delete or extract cell-anchored images. - manage_chart(action; opt chart_type data categories title x_title y_title at_cell sheet index titles_from_data show_axes allow_loss): Create, list or delete charts (bar, bar_horizontal, line, pie, doughnut, area, scatter); at_cell places one. - set_view(opt sheet freeze split gridlines headings zoom selection tab_color allow_loss): Set freeze or split panes, gridlines, headings, zoom, selection and tab color for a sheet; unset values stay. | |
| 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. |