ExcelWorkbookAgentTools Class
Provides AI agent tools for Excel workbook lifecycle management and I/O operations. Handles workbook creation, import, export, and manager.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Excel
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class ExcelWorkbookAgentTools : AgentToolBase
Constructors
ExcelWorkbookAgentTools(ExcelWorkbookManager, String)
Initializes a new instance of the ExcelWorkbookAgentTools class.
Declaration
public ExcelWorkbookAgentTools(ExcelWorkbookManager manager, string outputDirectory = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ExcelWorkbookManager | manager | The Excel workbook manager. |
| System.String | outputDirectory | Optional output directory for file operations. |
Methods
CreateWorkbook(String, String)
Creates an Excel workbook in memory or loads an existing workbook from a file.
Declaration
[Tool(Name = "CreateWorkbook", Description = "Creates an Excel workbook instance in memory. If filePath is null, creates a blank workbook; otherwise loads from the specified path.")]
public AgentToolResult CreateWorkbook([ToolParameter(Description = "Path to an existing Excel file, or null to create a new workbook")] string filePath = null, [ToolParameter(Description = "Password for encrypted workbook")] string password = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | Optional path to an existing Excel file. If null, creates a new blank workbook. |
| System.String | password | Optional password for encrypted workbooks. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the workbook ID of the created or loaded workbook. |
ExportWorkbook(String, String, String)
Exports an Excel workbook from memory to the file system.
Declaration
[Tool(Name = "ExportWorkbook", Description = "Exports the workbook to the file system in the specified format.")]
public AgentToolResult ExportWorkbook([ToolParameter(Description = "The ID of the workbook to export")] string workbookId, [ToolParameter(Description = "The file path to export to")] string filePath, [ToolParameter(Description = "The format: XLS, XLSX, XLSM, MD (default: XLSX)")] string version = "XLSX")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookId | The ID of the workbook to export. |
| System.String | filePath | The file path where the workbook should be saved. |
| System.String | version | The export format: XLS, XLSX, XLSM, MD (default: XLSX). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the export file path. |
GetAllWorkbooks()
Retrieves all workbook IDs currently in memory.
Declaration
[Tool(Name = "GetAllWorkbooks", Description = "Returns all workbook IDs in memory.")]
public AgentToolResult GetAllWorkbooks()
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing array of all workbook IDs. |
RemoveWorkbook(String)
Removes a specific workbook from memory by its ID.
Declaration
[Tool(Name = "RemoveWorkbook", Description = "Removes a specific workbook from memory by ID.")]
public AgentToolResult RemoveWorkbook([ToolParameter(Description = "The ID of the workbook to remove")] string workbookId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookId | The ID of the workbook to remove. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the workbook was removed successfully. |
SetActiveWorkbook(String)
Sets the active workbook context by ID.
Declaration
[Tool(Name = "SetActiveWorkbook", Description = "Changes the active workbook context by ID.")]
public AgentToolResult SetActiveWorkbook([ToolParameter(Description = "The ID of the workbook to set as active")] string workbookId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookId | The ID of the workbook to set as active. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |