ExcelConversionAgentTools Class
Provides AI agent tools for Excel conversion operations. Handles Excel to Image, Excel to HTML, Excel to ODS, and Excel to JSON conversions including worksheet, range, chart to image, workbook to HTML, workbook/worksheet to ODS, and workbook/worksheet/range to JSON with/without schema.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Excel
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class ExcelConversionAgentTools : AgentToolBase<IWorkbook>
Constructors
ExcelConversionAgentTools(DocumentStorageManager)
Initializes a new instance of the ExcelConversionAgentTools class (Mode 2 — DocumentStorage).
Declaration
public ExcelConversionAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
ExcelConversionAgentTools(ExcelWorkbookManager)
Initializes a new instance of the ExcelConversionAgentTools class (Mode 1 — InMemory).
Declaration
public ExcelConversionAgentTools(ExcelWorkbookManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| ExcelWorkbookManager | manager | The Excel workbook manager. |
Methods
ConvertChartToImage(String, String, Int32, String, String, String)
Converts an Excel chart to an image file.
Declaration
[Tool(Name = "ConvertChartToImage", Description = "Converts an Excel chart to an image file. Supports PNG and JPEG formats. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertChartToImage([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet containing the chart")] string worksheetName, [ToolParameter(Description = "The index of the chart in the worksheet (0-based)")] int chartIndex, [ToolParameter(Description = "The output file path for the image (e.g., chart.png)")] string outputPath, [ToolParameter(Description = "Image format: PNG (default), JPEG")] string imageFormat = "PNG", [ToolParameter(Description = "Scaling mode: Best (default), Normal")] string scalingMode = "Best")
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 containing the chart. |
| System.Int32 | chartIndex | The index of the chart in the worksheet (0-based). |
| System.String | outputPath | The output file path for the image (e.g., "chart.png"). |
| System.String | imageFormat | Optional image format: "PNG" (default), "JPEG". Default is "PNG". |
| System.String | scalingMode | Optional scaling mode: "Best" (default), "Normal". |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
ConvertRangeToJson(String, String, String, String, Boolean)
Converts a specific cell range to JSON format.
Declaration
[Tool(Name = "ConvertRangeToJson", Description = "Converts a specific cell range to JSON format with optional schema. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertRangeToJson([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 = "The cell range address (e.g., A1:D10)")] string rangeAddress, [ToolParameter(Description = "The output file path for the JSON file (e.g., range.json)")] string outputPath, [ToolParameter(Description = "Include schema in JSON output (default: true)")] bool includeSchema = true)
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 | rangeAddress | The cell range address (e.g., "A1:D10"). |
| System.String | outputPath | The output file path for the JSON file (e.g., "range.json"). |
| System.Boolean | includeSchema | Optional flag to include schema in the JSON output. Default is true. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
ConvertWorkbook(String, String, String)
Converts the workbook to the file system in the specified format (DocumentStorage mode only).
Declaration
[Tool(Name = "ConvertWorkbook", Description = "Converts the workbook to the file system in the specified format. Works only in DocumentStorage mode. workbookIdOrFilePath: The input file path from storage. Supported formats: xls, xlsx, xlsm, md")]
public AgentToolResult ConvertWorkbook([ToolParameter(Description = "The input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The file path to export to")] string outputPath, [ToolParameter(Description = "The format: xls, xlsx, xlsm, csv, tsv, md. Defaults to xlsx")] string formatType = "xlsx")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | |
| System.String | outputPath | |
| System.String | formatType |
Returns
| Type |
|---|
| AgentToolResult |
ConvertWorkbookToHtml(String, String, String)
Converts an entire workbook to an HTML file.
Declaration
[Tool(Name = "ConvertWorkbookToHtml", Description = "Converts an entire Excel workbook to an HTML file with styles, hyperlinks, images, and charts preserved. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertWorkbookToHtml([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The output file path for the HTML file (e.g., output.html)")] string outputPath, [ToolParameter(Description = "Text mode: DisplayText (default - shows formatted text), Value (shows cell values)")] string textMode = "DisplayText")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | outputPath | The output file path for the HTML file (e.g., "output.html"). |
| System.String | textMode | Optional text mode: "DisplayText" (shows formatted text), "Value" (shows cell values). Default is "DisplayText". |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
ConvertWorkbookToJson(String, String, Boolean)
Converts an entire workbook to JSON format.
Declaration
[Tool(Name = "ConvertWorkbookToJson", Description = "Converts an entire workbook to JSON format with optional schema. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertWorkbookToJson([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The output file path for the JSON file (e.g., output.json)")] string outputPath, [ToolParameter(Description = "Include schema in JSON output (default: true)")] bool includeSchema = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | workbookIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | outputPath | The output file path for the JSON file (e.g., "output.json"). |
| System.Boolean | includeSchema | Optional flag to include schema in the JSON output. Default is true. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
ConvertWorksheetToHtml(String, String, String, String)
Converts a specific worksheet to an HTML file.
Declaration
[Tool(Name = "ConvertWorksheetToHtml", Description = "Converts a specific Excel worksheet to an HTML file with styles, hyperlinks, images, and charts preserved. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertWorksheetToHtml([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet to convert")] string worksheetName, [ToolParameter(Description = "The output file path for the HTML file (e.g., worksheet.html)")] string outputPath, [ToolParameter(Description = "Text mode: DisplayText (default - shows formatted text), Value (shows cell values)")] string textMode = "DisplayText")
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 to convert. |
| System.String | outputPath | The output file path for the HTML file (e.g., "worksheet.html"). |
| System.String | textMode | Optional text mode: "DisplayText" (shows formatted text), "Value" (shows cell values). Default is "DisplayText". |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
ConvertWorksheetToImage(String, String, String, String, String, String)
Converts an entire worksheet to an image file.
Declaration
[Tool(Name = "ConvertWorksheetToImage", Description = "Converts an entire worksheet to an image file. Supports PNG, JPEG, BMP, GIF, and TIFF formats. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertWorksheetToImage([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet to convert")] string worksheetName, [ToolParameter(Description = "The cell range address (e.g., A1:D10)")] string rangeAddress, [ToolParameter(Description = "The output file path for the image (e.g., output.png)")] string outputPath, [ToolParameter(Description = "Image format: PNG (default), JPEG, BMP, GIF, TIFF")] string imageFormat = "PNG", [ToolParameter(Description = "Scaling mode: Best (default), NoScaling")] string scalingMode = "Best")
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 to convert. |
| System.String | rangeAddress | |
| System.String | outputPath | The output file path for the image (e.g., "output.png"). |
| System.String | imageFormat | Optional image format: "PNG", "JPEG", "BMP", "GIF", "TIFF". Default is "PNG". |
| System.String | scalingMode | Optional scaling mode: "Best" (default), "NoScaling". Best provides better quality. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
ConvertWorksheetToJson(String, String, String, Boolean)
Converts a specific worksheet to JSON format.
Declaration
[Tool(Name = "ConvertWorksheetToJson", Description = "Converts a specific worksheet to JSON format with optional schema. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ConvertWorksheetToJson([ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode)")] string workbookIdOrFilePath, [ToolParameter(Description = "The name of the worksheet to convert")] string worksheetName, [ToolParameter(Description = "The output file path for the JSON file (e.g., worksheet.json)")] string outputPath, [ToolParameter(Description = "Include schema in JSON output (default: true)")] bool includeSchema = true)
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 to convert. |
| System.String | outputPath | The output file path for the JSON file (e.g., "worksheet.json"). |
| System.Boolean | includeSchema | Optional flag to include schema in the JSON output. Default is true. |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the output file path. |
GetMarkdown(String)
Gets the Excel workbook content as Markdown.
Declaration
[Tool(Name = "GetMarkdown", Description = "Gets the Excel workbook content as Markdown using the given workbookId or filePath. Returns the Markdown content string of an Excel workbook.")]
public AgentToolResult GetMarkdown([ToolParameter(Description = "The ID of the workbook or file path")] string documentIdOrFilePath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result containing the Markdown content string or an error message. |
ImportMarkdown(String, String, String)
Imports Markdown content into an Excel workbook.
Declaration
[Tool(Name = "ImportMarkdown", Description = "Imports markdown content into an Excel workbook. markdownContent / filePath: The markdown content as a string or the file path to a markdown file. workbookIdOrFilePath: The workbook ID (InMemory mode) or input file path (DocumentStorage mode).")]
public AgentToolResult ImportMarkdown([ToolParameter(Description = "The markdown content as a string or the file path to a markdown file.")] string markdownContentOrFilePath, [ToolParameter(Description = "The workbook ID (InMemory mode) or input file path (DocumentStorage mode) of the destination document")] string workbookIdOrFilePath = null, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | markdownContentOrFilePath | The markdown content as a string or the file path to a markdown file. |
| System.String | workbookIdOrFilePath | The workbook ID (InMemory mode) or input file path (DocumentStorage mode) of the destination document. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure. |