New to Telerik Document Processing? Download free 30-day trial

Spreadsheet Tools

Telerik Document Processing provides a set of Spreadsheet document APIs exposing document processing capabilities (analysis, transformation, metadata extraction, and manipulation) optimized for consumption in agentic workflows within .NET AI applications.

Learn how to integrate the Agent Tools in your application: Getting Started with DPL Agent Tools.

Repositories

A repository is a place in memory where we keep the documents we currently work with. The available repositories for managing workbooks are:

Repository Description
IWorkbookRepository Provides a unified interface for managing spreadsheet workbooks. Extends IDocumentRepository with spreadsheet-specific creation capabilities.
InMemoryWorkbookRepository Repository for multi-document orchestration scenarios. Manages multiple workbooks in memory with support for creation and import.
SingleWorkbookRepository Provider for single-document analysis scenarios. Wraps an existing Workbook instance and does not support document creation.

Agent Tools

SpreadProcessingReadAgentTools

Provides read-only agent tools for querying and analyzing spreadsheet content without modifying the underlying document. It is designed for safe analysis-only scenarios, enabling agents to:

  • Inspect used ranges and worksheet metadata.
  • Read small cell ranges for display/inspection.
  • Find all occurrences of text/patterns with sampling.
  • Extract unique values from ranges.
  • Explore workbook and cell styles (names and properties).
  • Filter rows by exact match and aggregate results.
Tool Signature Description
FilterAndExtract
CallToolResult FilterAndExtract(
    int filterColumnIndex,
    List filterValues,
    List columnsToReturn,
    string worksheetName = null,
    string documentId = null,
    int maxSampleRows = 5)
Filters rows where the filter column matches any exact value from filterValues. Returns: Aggregated counts grouped by the values in columnsToReturn. Up to maxSampleRows sample rows (for verification) without reading the entire dataset.
GetUsedCellRange
CallToolResult GetUsedCellRange(
    string worksheetName = null,
    string documentId = null)
Returns the used range of the target (or active) worksheet as top-left and bottom-right zero-based indices. Useful for sizing, previews, and deriving safe subranges for reads.
FindAll
CallToolResult FindAll(
    string findWhat,
    Range[] searchRanges,
    string worksheetName = null,
    string documentId = null,
    int maxSampleLocations = 10)
Searches for findWhat across the specified ranges (or entire sheet if none provided). Case-insensitive.
GetUniqueValues
CallToolResult GetUniqueValues(
    Range range,
    string worksheetName = null,
    string documentId = null)
Returns all distinct values within the specified zero-based range. Great for categories, tags, or validating domain values in a column.
GetCellValues
CallToolResult GetCellValues(
    int fromRowIndex,
    int fromColumnIndex,
    int toRowIndex,
    int toColumnIndex,
    string worksheetName = null,
    string documentId = null)
Reads raw cell values from a small range and returns them as a string (for display/inspection).
ListAvailableStyles
CallToolResult ListAvailableStyles(
    string documentId = null)
Lists all style names defined in the workbook.
GetStyleProperties
CallToolResult GetStyleProperties(
    List styleNames,
    string documentId = null)
Returns detailed properties (font, border, alignment, fill, protection) for the specified existing style names. Use ListAvailableStyles first to discover valid names.
GetCellStyles
CallToolResult GetCellStyles(
    int fromRowIndex,
    int fromColumnIndex,
    int toRowIndex,
    int toColumnIndex,
    string worksheetName = null,
    string documentId = null)
Returns a 2D array of style names applied over the specified range. For spreadsheet formats only.
GetWorksheetNames
CallToolResult GetWorksheetNames(
    string documentId = null)
Returns a list of worksheet names in the workbook.
GetWorkbookStyles
CallToolResult GetWorkbookStyles(
    string documentId = null)
Returns all cell styles defined in the workbook including their detailed formatting properties.

SpreadProcessingWriteAgentTools

Exposes a set of methods designed for automations and AI agents to modify spreadsheet content and formatting in a controlled way.

Tool Signature Description
SetCellValues
public CallToolResult SetCellValues(
    int fromRowIndex,
    int fromColumnIndex,
    int toRowIndex,
    int toColumnIndex,
    List> values,
    string documentId = null,
    string worksheetName = null)
Writes values (or formulas) to a rectangular range.
SetCellFormula
public CallToolResult SetCellFormula(
    int rowIndex,
    int columnIndex,
    string formula,
    string worksheetName = null,
    string documentId = null)
Writes a single-cell formula.
SetCellStyles
public CallToolResult SetCellStyles(
    int fromRowIndex,
    int fromColumnIndex,
    int toRowIndex,
    int toColumnIndex,
    List> styleNames,
    string worksheetName = null,
    string documentId = null)
Applies named styles to a rectangular range.
AutoFitColumnsWidth
public CallToolResult AutoFitColumnsWidth(
    int fromColumnIndex,
    int toColumnIndex,
    string worksheetName = null,
    string documentId = null)
Auto-fits widths for a contiguous range of columns.
AutoFitRowsHeight
public CallToolResult AutoFitRowsHeight(
    int fromRowIndex,
    int toRowIndex,
    string worksheetName = null,
    string documentId = null)
Auto-fits heights for a contiguous range of rows.
MergeCells
public CallToolResult MergeCells(
    int fromRowIndex,
    int fromColumnIndex,
    int toRowIndex,
    int toColumnIndex,
    string worksheetName = null,
    string documentId = null)
Merges a rectangular range into a single cell.
UnmergeCells
public CallToolResult UnmergeCells(
    int fromRowIndex,
    int fromColumnIndex,
    int toRowIndex,
    int toColumnIndex,
    string worksheetName = null,
    string documentId = null)
Reverses merging, restoring individual cells.

SpreadProcessingWorksheetAgentTools

Provides worksheet management tools for creating, deleting, and renaming worksheets in a workbook. These tools modify the workbook structure only (they do not alter cell content, formatting, or data). It is designed to be used as part of agent/execution pipelines and exposes high-level operations through [Tool]-annotated methods for agent frameworks.

Tool Signature Description
AddWorksheets
public CallToolResult AddWorksheets(
string[] worksheetNames, 
tring documentId = null)
Adds one or more new worksheets to a workbook. Each worksheet name must be unique within the target workbook.
DeleteWorksheet
public CallToolResult DeleteWorksheet(
string worksheetName, 
string documentId = null)
Deletes a worksheet from a workbook by name. The workbook must always retain at least one worksheet; the last remaining worksheet cannot be deleted.
RenameWorksheet
public CallToolResult RenameWorksheet(
    string currentWorksheetName, 
    string newWorksheetName, 
    string documentId = null)
Renames an existing worksheet. The new name must be unique within the workbook.

SpreadProcessingFileManagementAgentTools

Provides document lifecycle management tools for spreadsheet workbooks—creating, listing, exporting, and importing in a way that is aligned with the Telerik AI Tools agent model. This class serves as a high-level agent tool wrapper that delegates core operations to an internal FileManagementTools instance backed by an IWorkbookRepository. The repository acts as the central document store (in-memory, file-based, or custom). Exports/Imports integrate with the file system via the configured outputDir.

Tool Signature Description
CreateWorkbook
public CallToolResult CreateWorkbook(
string documentId,
string[] worksheetNames)
Creates a new workbook in the repository with one or more worksheets. If documentId is null/empty, a unique ID is generated. Worksheet names must be unique within the workbook.
ListWorkbooks
public CallToolResult ListWorkbooks()
Returns a list of all workbooks known to the repository. Useful for discovery and for obtaining documentId values for subsequent operations.
ExportWorkbook
public CallToolResult ExportWorkbook(
string filePath,
DocumentFormat format,
string documentId = null)
Exports a repository workbook to the specified filePath using format. If documentId is not supplied, the repository’s current/default document is exported (if such concept is supported by your IWorkbookRepository).
ImportWorkbook
public CallToolResult ImportWorkbook(
string filePath,
DocumentFormat format,
string documentName = null)
Imports a workbook from a given file into the repository. If documentName is not provided, a unique ID is generated.

SpreadProcessingFormulaAgentTools

Provides read-only formula and calculation tools for spreadsheets handled through Telerik’s SpreadProcessing stack. It enables you to:

  • Evaluate spreadsheet formulas/expressions without modifying the underlying document.
  • Discover all available formulas/expressions.
  • Retrieve syntax and parameter information for one or more formulas before using them.
Tool Signature Description
CalculateFormulaWithoutChangingTheDocument
public CallToolResult CalculateFormulaWithoutChangingTheDocument(
string formula,
string documentId = null)
Evaluates a formula string (e.g., =SUM(A1:A10) or =(A1+A2)/2) without changing the document. Use this for any calculation, aggregation, count, or analysis instead of iterating raw cells.
ListAllFormulas
public CallToolResult ListAllFormulas(
string documentId = null)
Returns all supported formulas/expressions along with their category and description. Ideal for discovery and UI pickers.
GetFormulaInfo
public CallToolResult GetFormulaInfo(
List formulaNames,
string documentId = null)
Fetches description, syntax, and parameter metadata for the specified formula names.

See Also

In this article