excel_add_chart
Add a chart to an Excel sheet anchored at a target cell, with data from a specified range. Supports bar, line, pie, area, and scatter chart types.
Instructions
Add a chart to a sheet, anchored at target_cell.
Supported chart_type values: "bar", "line",
"pie", "area", "scatter". Any other value raises
:class:OfficeMCPError with ERR_INVALID_PARAMS
(VAL-EXCEL-056) and the workbook is not modified.
The chart's data is read from data_range (e.g. "A1:B5");
the first column is treated as categories and subsequent columns
as series. The chart is anchored at target_cell (e.g.
"D2") so its top-left corner coincides with that cell
(VAL-EXCEL-052).
Args:
path: Path to an existing .xlsx.
sheet: Name of the sheet that will own the chart.
chart_type: One of "bar", "line", "pie",
"area", "scatter".
data_range: A range reference like "A1:B5".
target_cell: A single cell reference like "D2". The
chart's top-left anchor is set to this cell.
title: Optional chart title. When supplied, it is set via
openpyxl's title API and survives a reload.
folder: Optional base folder for relative paths.
Returns:
{"ok": True}.
Raises:
OfficeMCPError: ERR_FILE_NOT_FOUND if the file is
missing, ERR_SHEET_NOT_FOUND for an unknown sheet,
ERR_INVALID_PARAMS for an unknown chart_type or
malformed data_range / target_cell,
ERR_CELL_PARSE for a malformed range,
ERR_UNSUPPORTED_FMT for non-.xlsx extensions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| sheet | Yes | ||
| chart_type | Yes | ||
| data_range | Yes | ||
| target_cell | Yes | ||
| title | No | ||
| folder | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||