ExcelChartAgentTools Class
Provides AI agent tools for Excel chart management operations. Handles chart creation, modification, customization, and removal.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Excel
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class ExcelChartAgentTools : AgentToolBase<IWorkbook>
Constructors
ExcelChartAgentTools(DocumentStorageManager)
Initializes a new instance of the ExcelChartAgentTools class (Mode 2 — DocumentStorage).
Declaration
public ExcelChartAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
ExcelChartAgentTools(ExcelWorkbookManager)
Initializes a new instance of the ExcelChartAgentTools class (Mode 1 — InMemory).
Declaration
public ExcelChartAgentTools(ExcelWorkbookManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| ExcelWorkbookManager | manager | The Excel workbook manager. |
Methods
AddSeriesToChart(String, String, Int32, String, String, String, String)
Adds a series to an existing chart.
Declaration
[Tool(Name = "AddSeriesToChart", Description = "Adds a new series to an existing chart. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult AddSeriesToChart([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet")] string worksheetName, [ToolParameter(Description = "Index of the chart (0-based)")] int chartIndex, [ToolParameter(Description = "Name of the series to add")] string seriesName, [ToolParameter(Description = "Range containing values (e.g., C2:C6)")] string valuesRange, [ToolParameter(Description = "Range containing category labels (e.g., A2:A6)")] string categoryLabelsRange = "", [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | worksheetName | The name of the worksheet. |
| System.Int32 | chartIndex | The index of the chart (0-based). |
| System.String | seriesName | The name of the series to add. |
| System.String | valuesRange | The range containing the values (e.g., "C2:C6"). |
| System.String | categoryLabelsRange | The range containing category labels (e.g., "A2:A6"). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |
CreateChart(String, String, String, String, Boolean, Int32, Int32, Int32, Int32, String)
Creates a chart in the specified worksheet from a data range.
Declaration
[Tool(Name = "CreateChart", Description = "Creates a chart from a data range in the worksheet. Supports various chart types like Column_Clustered, Line, Pie, Bar_Clustered, Area, etc. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult CreateChart([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet")] string worksheetName, [ToolParameter(Description = "Chart type (e.g., Column_Clustered, Line, Pie, Bar_Clustered, Area, Column_Stacked, Line_Markers)")] string chartType, [ToolParameter(Description = "Data range for the chart (e.g., A1:C6)")] string dataRange, [ToolParameter(Description = "True if series are in rows, false if in columns (default: false)")] bool isSeriesInRows = false, [ToolParameter(Description = "Top row for chart positioning (default: 8)")] int topRow = 8, [ToolParameter(Description = "Left column for chart positioning (default: 1)")] int leftColumn = 1, [ToolParameter(Description = "Bottom row for chart positioning (default: 23)")] int bottomRow = 23, [ToolParameter(Description = "Right column for chart positioning (default: 8)")] int rightColumn = 8, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | worksheetName | The name of the worksheet. |
| System.String | chartType | The type of chart (e.g., Column_Clustered, Line, Pie, Bar_Clustered). |
| System.String | dataRange | The data range for the chart (e.g., "A1:C6"). |
| System.Boolean | isSeriesInRows | True if series are in rows, false if in columns. |
| System.Int32 | topRow | Optional top row for chart positioning (default: 8). |
| System.Int32 | leftColumn | Optional left column for chart positioning (default: 1). |
| System.Int32 | bottomRow | Optional bottom row for chart positioning (default: 23). |
| System.Int32 | rightColumn | Optional right column for chart positioning (default: 8). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the chart index. |
CreateChartWithSeries(String, String, String, String, String, String, Int32, Int32, Int32, Int32, String)
Creates a chart by adding series one by one.
Declaration
[Tool(Name = "CreateChartWithSeries", Description = "Creates a chart and adds a series with values and category labels. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult CreateChartWithSeries([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet")] string worksheetName, [ToolParameter(Description = "Chart type (e.g., Line, Column_Clustered, Bar_Clustered)")] string chartType, [ToolParameter(Description = "Name of the series")] string seriesName, [ToolParameter(Description = "Range containing values (e.g., B2:B6)")] string valuesRange, [ToolParameter(Description = "Range containing category labels (e.g., A2:A6)")] string categoryLabelsRange, [ToolParameter(Description = "Top row for chart positioning (default: 8)")] int topRow = 8, [ToolParameter(Description = "Left column for chart positioning (default: 1)")] int leftColumn = 1, [ToolParameter(Description = "Bottom row for chart positioning (default: 23)")] int bottomRow = 23, [ToolParameter(Description = "Right column for chart positioning (default: 8)")] int rightColumn = 8, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | worksheetName | The name of the worksheet. |
| System.String | chartType | The type of chart (e.g., Line, Column_Clustered, Bar_Clustered). |
| System.String | seriesName | The name of the series. |
| System.String | valuesRange | The range containing the values (e.g., "B2:B6"). |
| System.String | categoryLabelsRange | The range containing category labels (e.g., "A2:A6"). |
| System.Int32 | topRow | Optional top row for chart positioning (default: 8). |
| System.Int32 | leftColumn | Optional left column for chart positioning (default: 1). |
| System.Int32 | bottomRow | Optional bottom row for chart positioning (default: 23). |
| System.Int32 | rightColumn | Optional right column for chart positioning (default: 8). |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the chart index and series information. |
SetChartElements(String, String, Int32, Int32, String, Boolean, String, Boolean, Boolean, Boolean, String, String, String, String)
Sets the chart title.
Declaration
[Tool(Name = "SetChartElement", Description = "Sets the elements of a chart. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult SetChartElements([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet")] string worksheetName, [ToolParameter(Description = "Index of the chart (0-based)")] int chartIndex, [ToolParameter(Description = "Index of the series (0-based)")] int seriesIndex, [ToolParameter(Description = "Title text for the chart")] string title, [ToolParameter(Description = "True to show legend, false to hide")] bool hasLegend, [ToolParameter(Description = "Legend position(ONLY exact values): Bottom, Top, Left, Right, Corner (default: Bottom)")] string position = "Bottom", [ToolParameter(Description = "Show values in data labels (default: true)")] bool showValue = true, [ToolParameter(Description = "Show category names in data labels (default: false)")] bool showCategoryName = false, [ToolParameter(Description = "Show series names in data labels (default: false)")] bool showSeriesName = false, [ToolParameter(Description = "Data label position: Outside, Inside, Center, etc. (default: Outside)")] string dataLabelposition = "Outside", [ToolParameter(Description = "Title for category (horizontal) axis")] string categoryAxisTitle = null, [ToolParameter(Description = "Title for value (vertical) axis")] string valueAxisTitle = null, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | |
| System.String | worksheetName | |
| System.Int32 | chartIndex | |
| System.Int32 | seriesIndex | |
| System.String | title | |
| System.Boolean | hasLegend | |
| System.String | position | |
| System.Boolean | showValue | |
| System.Boolean | showCategoryName | |
| System.Boolean | showSeriesName | |
| System.String | dataLabelposition | |
| System.String | categoryAxisTitle | |
| System.String | valueAxisTitle | |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |