ClassSingleWorkbookRepository
Repository for single-document analysis scenarios. Wraps an existing Workbook instance and does not support document creation.
Definition
Namespace:Telerik.Documents.AI.AgentTools.Spreadsheet
Assembly:Telerik.Documents.AI.AgentTools.Spreadsheet.dll
Syntax:
public class SingleWorkbookRepository : IWorkbookRepository, IDocumentRepository<Workbook>, IDocumentRepository, ISupportPdfExport
Inheritance: objectSingleWorkbookRepository
Implements:
Constructors
SingleWorkbookRepository(Workbook, string)
Initializes a new instance wrapping an existing workbook.
Declaration
public SingleWorkbookRepository(Workbook workbook, string documentName = null)
Parameters
workbook
The workbook to wrap.
documentName
Optional display name for the document.
Exceptions
Thrown when workbook is null.
Properties
DocumentType
Gets the type of the document represented by this instance.
Declaration
public DocumentType DocumentType { get; }
Property Value
Implements
SupportsCreation
Gets a value indicating whether this repository supports creating new documents. Single-document repositories typically return false.
SupportsMultipleDocuments
Gets a value indicating whether this repository supports managing multiple documents. Single-document repositories return false.
Declaration
public bool SupportsMultipleDocuments { get; }
Property Value
Implements
Methods
Clear()
Removes all documents from the repository.
Declaration
public void Clear()
Implements
CreateDocument(string, string[])
Creates a document using the specified document identifier and arguments.
Declaration
public string CreateDocument(string documentId, string[] worksheetNames)
Parameters
documentId
The unique identifier for the document to be created. Cannot be null or empty.
worksheetNames
string[]
Returns
A string containing the contents of the created document.
Implements
Export(string, DocumentFormat, Stream)
Exports a document to a byte array in the specified format.
Declaration
public void Export(string documentId, DocumentFormat format, Stream destinationStream)
Parameters
documentId
The document identifier to export. If null, exports the default/current document.
format
The target format for export.
destinationStream
The stream to which the document will be exported.
Exceptions
Thrown when the specified format is not supported.
Thrown when the specified document ID does not exist.
Implements
ExportToPdf(string, Stream)
Exports the specified document to PDF format and writes the result to the provided stream.
Declaration
public void ExportToPdf(string documentId, Stream destinationStream)
Parameters
documentId
The unique identifier of the document to export. Cannot be null or empty.
destinationStream
The stream to which the generated PDF will be written. Must be writable and remain open for the duration of the operation.
Implements
GetDocument(string)
Gets a document by its identifier.
Declaration
public Workbook GetDocument(string documentId = null)
Parameters
documentId
The document identifier. If null, returns the default/current document. In single-document mode, this parameter is ignored.
Returns
The requested document instance.
Exceptions
Thrown when the specified document ID does not exist.
Thrown when no documents are available and documentId is null.
Implements
GetDocumentAsObject(string)
Gets a document by its identifier.
Declaration
public object GetDocumentAsObject(string documentId = null)
Parameters
documentId
The document identifier. If null, returns the default/current document. In single-document mode, this parameter is ignored.
Returns
The requested document instance.
Exceptions
Thrown when the specified document ID does not exist.
Thrown when no documents are available and documentId is null.
Implements
Import(Stream, DocumentFormat, string)
Imports a document from a byte array and adds it to the repository.
Declaration
public string Import(Stream data, DocumentFormat format, string documentName = null)
Parameters
data
The document content as a byte array.
format
The format of the document being imported.
documentName
Optional name for the imported document.
Returns
The document ID assigned to the imported document.
Exceptions
Thrown when the repository does not support creation or the format is not supported.
Implements
ListDocuments()
Lists all documents currently managed by this repository.
Declaration
public IEnumerable<DocumentInfo> ListDocuments()
Returns
Collection of document metadata.
Implements
MergeAndExport(string[], Stream, DocumentFormat)
Merges the specified source documents and exports the combined result to the provided stream in the specified format.
Declaration
public void MergeAndExport(string[] sourceFileIds, Stream stream, DocumentFormat exportFormat)
Parameters
sourceFileIds
string[]
An array of identifiers for the source documents to merge. The order of identifiers determines the order in which documents are merged. Cannot be null or empty.
stream
The stream to which the merged document will be written. Must be writable and remain open for the duration of the operation.
exportFormat
The format in which to export the merged document.
Implements
RemoveDocument(string)
Removes a document from the repository.