Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

ExcelDocument

OfficeIMO.Excel

Namespace
OfficeIMO.Excel
Assembly
OfficeIMO.Excel
Source revision
0eef6a5756b9 with working tree changes
Implements
IDisposable IAsyncDisposable
Attributes
DefaultMember("Item")

Represents an Excel document and provides methods for creating, loading and saving spreadsheets.

Inheritance

  • object
  • ExcelDocument

Usage

Explore 24 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 10

Constructors

Methods

public IReadOnlyDictionary<ExcelSheet, ExcelHyperlinkInfo> AddBackLinksToToc(string tocSheetName = "TOC", int row = 2, int col = 1, string text = "← TOC") #

Adds a small back link to the TOC on each worksheet at the given cell (default A2).

Parameters

tocSheetName string = "TOC" optional
row int = 2 optional
col int = 1 optional
text string = "← TOC" optional

Returns

IReadOnlyDictionary<ExcelSheet, ExcelHyperlinkInfo>
AddMacro 3 overloads
public ExcelMacroProject AddMacro(byte[] data) #

Adds or replaces a vbaProject.bin payload.

Parameters

data byte[] required
public ExcelMacroProject AddMacro(string filePath) #

Adds or replaces a VBA project from a file.

Parameters

filePath string required
public ExcelMacroProject AddMacro(Stream stream, long? maxBytes = null) #

Adds or replaces a VBA project from a readable stream.

Parameters

stream System.IO.Stream required
maxBytes long? = null optional
public ExcelPivotInteractionInfo AddPivotSlicer(string pivotTableName, string sourceField, string worksheetName, ExcelSlicerViewOptions? options = null) #

Adds a native Excel slicer view bound to a PivotTable field.

Parameters

pivotTableName string required
sourceField string required
worksheetName string required
options OfficeIMO.Excel.ExcelSlicerViewOptions? = null optional
public ExcelPackagePartInfo AddPivotSlicerCache(string pivotTableName, string sourceField, string? cacheName = null) #

Adds slicer cache metadata bound to a validated pivot table field.

Parameters

pivotTableName string required
sourceField string required
cacheName string? = null optional
public ExcelPivotInteractionInfo AddPivotTimeline(string pivotTableName, string sourceField, string worksheetName, ExcelTimelineViewOptions? options = null) #

Adds a native Excel timeline view bound to a date-only PivotTable field.

Parameters

pivotTableName string required
sourceField string required
worksheetName string required
options OfficeIMO.Excel.ExcelTimelineViewOptions? = null optional
public ExcelPackagePartInfo AddPivotTimelineCache(string pivotTableName, string sourceField, string? cacheName = null) #

Adds timeline cache metadata bound to a validated pivot table field.

Parameters

pivotTableName string required
sourceField string required
cacheName string? = null optional
public ExcelPowerQueryMetadataResult AddPowerQueryMetadata(ExcelPowerQueryMetadataOptions options) #

Authors safe connection/query-table metadata for Excel-compatible applications to own and refresh. OfficeIMO writes metadata only; it does not execute Power Query M or contact external systems.

Parameters

options OfficeIMO.Excel.ExcelPowerQueryMetadataOptions required
public ExcelQueryBackedTableInfo AddQueryBackedTable(ExcelQueryBackedTableOptions options) #

Creates a native query-backed worksheet table without executing its command.

Parameters

options OfficeIMO.Excel.ExcelQueryBackedTableOptions required
AddSheet 3 overloads
public ExcelSheet AddSheet(string worksheetName = "") #

Adds a worksheet to the document.

Parameters

worksheetName string = "" optional
Worksheet name.

Returns

ExcelSheet Created ExcelSheet instance.
public ExcelSheet AddSheet(string worksheetName, ExcelSheetNameValidationMode validationMode) #

Adds a worksheet to the document with control over name validation.

Parameters

worksheetName string required
Requested worksheet name.
validationMode OfficeIMO.Excel.ExcelSheetNameValidationMode required
How to validate the sheet name: None (no checks), Sanitize (coerce), or Strict (throw on invalid).

Returns

ExcelSheet Created ExcelSheet instance.
public ExcelSheet AddSheet(string worksheetName, ExcelSheetNameValidationMode validationMode, CancellationToken cancellationToken) #

Adds a worksheet, observing cancellation while earlier deferred worksheet data is materialized.

Parameters

worksheetName string required
Requested worksheet name.
validationMode OfficeIMO.Excel.ExcelSheetNameValidationMode required
How to validate the worksheet name.
cancellationToken System.Threading.CancellationToken required
Cancels deferred materialization and worksheet creation.

Returns

ExcelSheet The created worksheet.

Exceptions

  • OperationCanceledException – The operation was canceled.
public ExcelSheet AddTableOfContents(string sheetName = "TOC", bool placeFirst = true, bool withHyperlinks = true, bool includeNamedRanges = false, bool includeHiddenNamedRanges = false, Predicate<string>? rangeNameFilter = null, bool styled = true) #

Adds or refreshes a visually styled Table of Contents sheet with hyperlinks.

Parameters

sheetName string = "TOC" optional
TOC sheet name.
placeFirst bool = true optional
Move TOC as the first sheet.
withHyperlinks bool = true optional
Create internal hyperlinks.
includeNamedRanges bool = false optional
Also list defined names in a dedicated column.
includeHiddenNamedRanges bool = false optional
When listing defined names, include ones marked Hidden.
rangeNameFilter System.Predicate<string>? = null optional
Optional filter to include only matching defined names.
styled bool = true optional
When true, renders a banner and a formatted table with AutoFilter.

Returns

ExcelSheet
public ExcelPackagePartInfo AddWorkbookConnectionMetadata(string xml) #

Adds caller-supplied workbook connection metadata XML as a workbook package part. OfficeIMO preserves this metadata but does not execute or refresh external connections.

Parameters

xml string required
Connection metadata XML.

Returns

ExcelPackagePartInfo Information identifying the added or updated package part.
public ExcelPackagePartInfo AddWorkbookMetadataPart(string relationshipType, string contentType, string xml, string targetExtension = "xml") #

Adds caller-supplied XML as a workbook package metadata part.

Parameters

relationshipType string required
Open XML relationship type.
contentType string required
Package part content type.
xml string required
Metadata XML.
targetExtension string = "xml" optional
Target extension for the generated package part.

Returns

ExcelPackagePartInfo Information identifying the added package part.
public ExcelPackagePartInfo AddWorkbookSlicerCache(ExcelSlicerCacheOptions options) #

Adds OfficeIMO-owned workbook-level slicer binding metadata. This does not impersonate a native Excel slicer-cache part; native cache structures and UI shapes must be materialized separately.

Parameters

options OfficeIMO.Excel.ExcelSlicerCacheOptions required
Slicer cache metadata options.

Returns

ExcelPackagePartInfo Information identifying the added package part.
public ExcelPackagePartInfo AddWorkbookTimelineCache(ExcelTimelineCacheOptions options) #

Adds OfficeIMO-owned workbook-level timeline binding metadata. This does not impersonate a native Excel timeline-cache part; native cache structures and UI shapes must be materialized separately.

Parameters

options OfficeIMO.Excel.ExcelTimelineCacheOptions required
Timeline cache metadata options.

Returns

ExcelPackagePartInfo Information identifying the added package part.
public ExcelPackagePartInfo AddWorksheetMetadataPart(ExcelSheet sheet, string relationshipType, string contentType, string xml, string targetExtension = "xml") #

Adds caller-supplied XML as a worksheet package metadata part.

Parameters

sheet OfficeIMO.Excel.ExcelSheet required
Worksheet that owns the metadata part.
relationshipType string required
Open XML relationship type.
contentType string required
Package part content type.
xml string required
Metadata XML.
targetExtension string = "xml" optional
Target extension for the generated package part.

Returns

ExcelPackagePartInfo Information identifying the added package part.
public ExcelPackagePartInfo AddWorksheetQueryTableMetadata(string worksheetName, string xml) #

Adds caller-supplied query-table metadata XML as a worksheet package part. OfficeIMO preserves this metadata but does not execute or refresh external queries.

Parameters

worksheetName string required
Worksheet that owns the query-table metadata.
xml string required
Query-table metadata XML.

Returns

ExcelPackagePartInfo Information identifying the added package part.
public ExcelAccessibilityReport AnalyzeAccessibility() #

Reports workbook accessibility and compliance issues such as missing alt text, hidden sheets, merged cells, and missing table headers.

public ExcelFormulaAnalysisReport AnalyzeFormulas() #

Analyzes formulas for references, opening brackets that may indicate special references, and volatile functions.

ApplyTemplate 4 overloads
public int ApplyTemplate(IDictionary<string, object?> values, IFormatProvider? provider = null, bool throwOnMissing = false) #

Replaces {{Marker}} placeholders across all worksheets using the supplied values.

Parameters

values System.Collections.Generic.IDictionary<string, object?> required
provider System.IFormatProvider? = null optional
throwOnMissing bool = false optional

Returns

int
public int ApplyTemplate(IDictionary<string, object?> values, ExcelTemplateOptions options) #

Replaces {{Marker}} placeholders across all worksheets using the supplied values and options.

Parameters

values System.Collections.Generic.IDictionary<string, object?> required
options OfficeIMO.Excel.ExcelTemplateOptions required

Returns

int
public int ApplyTemplate(object model, IFormatProvider? provider = null, bool throwOnMissing = false) #

Replaces {{Marker}} placeholders across all worksheets using public properties from the supplied model. Nested properties are exposed as dotted marker names, for example {{Customer.Name}}.

Parameters

model object required
provider System.IFormatProvider? = null optional
throwOnMissing bool = false optional

Returns

int
public int ApplyTemplate(object model, ExcelTemplateOptions options) #

Replaces {{Marker}} placeholders across all worksheets using public properties from the supplied model and options. Nested properties are exposed as dotted marker names, for example {{Customer.Name}}.

Parameters

model object required
options OfficeIMO.Excel.ExcelTemplateOptions required

Returns

int
public int ApplyTemplateSheets(string templateSheetName, IEnumerable<IDictionary<string, object?>> sheets, Func<IDictionary<string, object?>, int, string>? sheetNameSelector = null, ExcelTemplateOptions? options = null) #

Repeats a template worksheet for each supplied value dictionary and applies markers to each generated sheet.

Parameters

templateSheetName string required
Worksheet to use as the sheet template.
sheets System.Collections.Generic.IEnumerable<System.Collections.Generic.IDictionary<string, object?>> required
Per-sheet value dictionaries.
sheetNameSelector System.Func<System.Collections.Generic.IDictionary<string, object?>, int, string>? = null optional
Optional generated sheet name selector. The index is zero-based.
options OfficeIMO.Excel.ExcelTemplateOptions? = null optional
Optional template binding options.

Returns

int Total marker replacements across all generated sheets.
public int ApplyTemplateSheets<T>(string templateSheetName, IEnumerable<T?> models, Func<T?, int, string>? sheetNameSelector = null, ExcelTemplateOptions? options = null) #

Repeats a template worksheet for each supplied model and applies markers to each generated sheet. Public properties are exposed as marker names, including nested dotted names.

Type Parameters

T

Parameters

templateSheetName string required
Worksheet to use as the sheet template.
models System.Collections.Generic.IEnumerable<T?> required
Per-sheet models.
sheetNameSelector System.Func<T?, int, string>? = null optional
Optional generated sheet name selector. The index is zero-based.
options OfficeIMO.Excel.ExcelTemplateOptions? = null optional
Optional template binding options.

Returns

int Total marker replacements across all generated sheets.
public ExcelDocument ApplyTheme(OfficeTheme theme) #

Applies the shared palette and font scheme to the workbook and uses it for subsequent authoring defaults.

Parameters

theme OfficeIMO.OfficeTheme required
public int Calculate() #

Calculates formulas that are supported by OfficeIMO's lightweight formula engine and writes cached values. Unsupported formulas are preserved unchanged for Excel-compatible applications to calculate.

Returns

int The number of formula cells with updated cached values.
public void ClearCachedFormulaResults() #

Removes cached values from all formula cells.

public void ClearWriteReservation() #

Removes workbook write-reservation metadata.

public IReadOnlyList<ExcelRangeDifference> CompareRanges(ExcelSheet leftSheet, string leftRange, ExcelSheet rightSheet, string rightRange, ExcelRangeCompareOptions? options = null) #

Compares two worksheet ranges and returns cell-level differences.

Parameters

leftSheet OfficeIMO.Excel.ExcelSheet required
leftRange string required
rightSheet OfficeIMO.Excel.ExcelSheet required
rightRange string required
options OfficeIMO.Excel.ExcelRangeCompareOptions? = null optional

Returns

IReadOnlyList<ExcelRangeDifference>
CompareWorkbook 2 overloads
public ExcelWorkbookDiffReport CompareWorkbook(ExcelDocument other, ExcelWorkbookDiffOptions options) #

Compares this workbook with another workbook using configurable structural, value, style, table, comment, and metadata checks.

Parameters

other OfficeIMO.Excel.ExcelDocument required
options OfficeIMO.Excel.ExcelWorkbookDiffOptions required
public ExcelWorkbookDiffReport CompareWorkbook(ExcelDocument other, int maxDifferences = 200) #

Compares this workbook with another workbook by sheets, dimensions, formulas, and visible cell text.

Parameters

other OfficeIMO.Excel.ExcelDocument required
Workbook to compare with this workbook.
maxDifferences int = 200 optional
Maximum number of differences to record. A nonpositive value records no differences.

Returns

ExcelWorkbookDiffReport A report containing differences up to the requested limit.
public IReadOnlyList<ExcelRangeDifference> CompareWorksheets(ExcelSheet leftSheet, ExcelSheet rightSheet, ExcelRangeCompareOptions? options = null) #

Compares the used ranges of two worksheets.

Parameters

leftSheet OfficeIMO.Excel.ExcelSheet required
rightSheet OfficeIMO.Excel.ExcelSheet required
options OfficeIMO.Excel.ExcelRangeCompareOptions? = null optional

Returns

IReadOnlyList<ExcelRangeDifference>
public void ConfigureFullCalculationOnOpen() #

Requests a full workbook recalculation when the file is opened.

CopyWorksheet 2 overloads
public ExcelSheet CopyWorksheet(string sourceSheetName, string newSheetName, ExcelSheetNameValidationMode validationMode = Sanitize) #

Copies a worksheet within this workbook. Self-qualified references in the copy target the new worksheet; references to other sheets remain unchanged.

Parameters

sourceSheetName string required
Name of the worksheet to copy.
newSheetName string required
Requested name for the copied worksheet.
validationMode OfficeIMO.Excel.ExcelSheetNameValidationMode = Sanitize optional
How to validate or sanitize newSheetName.

Returns

ExcelSheet The copied worksheet.
public ExcelSheet CopyWorksheet(ExcelSheet sourceSheet, string newSheetName, ExcelSheetNameValidationMode validationMode = Sanitize) #

Copies a worksheet within this workbook. Self-qualified references in the copy target the new worksheet; references to other sheets remain unchanged.

Parameters

sourceSheet OfficeIMO.Excel.ExcelSheet required
Worksheet to copy.
newSheetName string required
Requested name for the copied worksheet.
validationMode OfficeIMO.Excel.ExcelSheetNameValidationMode = Sanitize optional
How to validate or sanitize newSheetName.

Returns

ExcelSheet The copied worksheet.
CopyWorksheetFrom 2 overloads
public ExcelSheet CopyWorksheetFrom(ExcelDocument sourceDocument, string sourceSheetName, string newSheetName, ExcelSheetNameValidationMode validationMode = Sanitize) #

Copies a worksheet from another workbook into this workbook.

Parameters

sourceDocument OfficeIMO.Excel.ExcelDocument required
Workbook containing the source worksheet.
sourceSheetName string required
Name of the worksheet to copy.
newSheetName string required
Requested name for the copied worksheet.
validationMode OfficeIMO.Excel.ExcelSheetNameValidationMode = Sanitize optional
How to validate or sanitize newSheetName.

Returns

ExcelSheet The copied worksheet.
public ExcelSheet CopyWorksheetFrom(ExcelDocument sourceDocument, string sourceSheetName, string newSheetName, ExcelSheetNameValidationMode validationMode, ExcelWorksheetCopyOptions? options) #

Copies a worksheet from another workbook into this workbook.

Parameters

sourceDocument OfficeIMO.Excel.ExcelDocument required
Workbook containing the source worksheet.
sourceSheetName string required
Name of the worksheet to copy.
newSheetName string required
Requested name for the copied worksheet.
validationMode OfficeIMO.Excel.ExcelSheetNameValidationMode required
How to validate or sanitize newSheetName.
options OfficeIMO.Excel.ExcelWorksheetCopyOptions? required
Copy strategy options.

Returns

ExcelSheet The copied worksheet.
Create 3 overloads
public static ExcelDocument Create(ExcelCreateOptions? options = null) #

Creates a detached workbook that must be saved explicitly to a path or stream.

Parameters

options OfficeIMO.Excel.ExcelCreateOptions? = null optional
Creation options. SaveOnDispose is invalid without an associated destination.
public static ExcelDocument Create(string filePath, ExcelCreateOptions? options = null) #

Creates a new Excel document at the specified path.

Parameters

filePath string required
Path to the new file.
options OfficeIMO.Excel.ExcelCreateOptions? = null optional
Creation and persistence options.

Returns

ExcelDocument Created ExcelDocument instance.
public static ExcelDocument Create(Stream stream, ExcelCreateOptions? options = null) #

Creates a new Excel document in memory and optionally persists it to the provided stream on dispose.

Parameters

stream System.IO.Stream required
Destination stream to receive the workbook package.
options OfficeIMO.Excel.ExcelCreateOptions? = null optional
Creation and persistence options.

Returns

ExcelDocument Created ExcelDocument instance.
public ExcelWorkbookDataReader CreateDataReader(ExcelReaderOptions? options = null) #

Creates a forward-only data reader over this open workbook document. The returned reader does not close the document.

Parameters

options OfficeIMO.Excel.ExcelReaderOptions? = null optional
CreateWriter 4 overloads
public static ExcelWorkbookWriter CreateWriter(string path, ExcelWriterOptions? options = null, OfficeTheme? theme = null) #

Creates a bounded-memory XLSX writer. Dispose publishes the completed file atomically.

Parameters

path string required
options OfficeIMO.Excel.ExcelWriterOptions? = null optional
theme OfficeIMO.OfficeTheme? = null optional
public static ExcelWorkbookWriter CreateWriter(ExcelFileFormat format, string path, ExcelWriterOptions? options = null, OfficeTheme? theme = null) #

Creates a row writer for the selected Excel format. Dispose publishes the file atomically.

Parameters

format OfficeIMO.Excel.ExcelFileFormat required
path string required
options OfficeIMO.Excel.ExcelWriterOptions? = null optional
theme OfficeIMO.OfficeTheme? = null optional
public static ExcelWorkbookWriter CreateWriter(Stream stream, ExcelWriterOptions? options = null, OfficeTheme? theme = null, bool leaveOpen = false) #

Creates a bounded-memory XLSX writer over a writable stream, including non-seekable streams.

Parameters

stream System.IO.Stream required
options OfficeIMO.Excel.ExcelWriterOptions? = null optional
theme OfficeIMO.OfficeTheme? = null optional
leaveOpen bool = false optional
public static ExcelWorkbookWriter CreateWriter(ExcelFileFormat format, Stream stream, ExcelWriterOptions? options = null, OfficeTheme? theme = null, bool leaveOpen = false) #

Creates a row writer for the selected format over a writable, optionally non-seekable stream.

Parameters

format OfficeIMO.Excel.ExcelFileFormat required
stream System.IO.Stream required
options OfficeIMO.Excel.ExcelWriterOptions? = null optional
theme OfficeIMO.OfficeTheme? = null optional
leaveOpen bool = false optional
public ExcelNamedStyleInfo DefineNamedStyle(string name, ExcelStyleDefinition definition, bool hidden = false) #

Creates or replaces a custom named style from a standalone definition. Existing cells using the unchanged named style receive the replacement formatting.

Parameters

name string required
definition OfficeIMO.Excel.ExcelStyleDefinition required
hidden bool = false optional
public void Dispose() #

Releases resources used by the document.

public async ValueTask DisposeAsync() #

Asynchronously releases resources used by the document.

Returns

ValueTask
public ExcelDocument EnsureWorkbookTheme() #

Ensures the workbook contains the shared default theme and stylesheet parts.

public OfficeConversionResult<byte[], ExcelSpreadsheetXmlReport> ExportSpreadsheetXml(ExcelSpreadsheetXmlOptions? options = null) #

Exports the current workbook to XML Spreadsheet 2003 data interchange bytes and reports unsupported content. Does not change the associated file path. XML is a separate explicit route, not an alias for XLSX Save.

Parameters

options OfficeIMO.Excel.ExcelSpreadsheetXmlOptions? = null optional

Returns

OfficeConversionResult<byte[], ExcelSpreadsheetXmlReport>
public byte[] ExtractEmbeddedPayload(string id, long? maxBytes = null) #

Extracts an embedded payload by its package-local id.

Parameters

id string required
maxBytes long? = null optional

Returns

byte[]
public byte[] ExtractMacros(long? maxBytes = null) #

Extracts the VBA project, or an empty array when no project exists.

Parameters

maxBytes long? = null optional

Returns

byte[]
public IReadOnlyDictionary<string, string> GetAllNamedRanges(ExcelSheet? scope = null) #

Returns all defined names with their A1 ranges, optionally limited to a sheet scope.

Parameters

scope OfficeIMO.Excel.ExcelSheet? = null optional

Returns

IReadOnlyDictionary<string, string>
GetEmbeddedPayloads 2 overloads
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions options, CancellationToken cancellationToken = default) #

Inventories payloads within explicit count/member/aggregate/work ceilings without scanning unrequested bytes unless hashing is requested.

Parameters

options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions required
cancellationToken System.Threading.CancellationToken = default optional

Returns

IReadOnlyList<OfficeEmbeddedPayloadInfo>
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(bool includeSha256 = false) #

Gets embedded package, OLE, and ActiveX payload metadata.

Parameters

includeSha256 bool = false optional

Returns

IReadOnlyList<OfficeEmbeddedPayloadInfo>
public ExcelRange? GetNamedRange(string name, ExcelSheet? scope = null) #

Returns the range a defined name refers to, on the worksheet the name points at. When scope is supplied, a name local to that sheet wins over a workbook name.

Parameters

name string required
Defined name to resolve.
scope OfficeIMO.Excel.ExcelSheet? = null optional
Optional sheet scope to resolve a local name.

Returns

ExcelRange? The range, or null when the name does not exist or does not refer to one rectangular cell range on an existing worksheet (for example a constant, a formula or a #REF! reference). Use ExcelDocument.ListNamedRanges for the stored text of every name.
public IReadOnlyList<ExcelNamedStyleInfo> GetNamedStyles() #

Lists workbook named styles.

Returns

IReadOnlyList<ExcelNamedStyleInfo>
public IReadOnlyList<ExcelPivotInteractionInfo> GetPivotInteractions() #

Returns native slicer and timeline views across the workbook.

Returns

IReadOnlyList<ExcelPivotInteractionInfo>
public IReadOnlyList<ExcelPivotTableInfo> GetPivotTables() #

Returns all pivot tables defined in the workbook.

Returns

IReadOnlyList<ExcelPivotTableInfo>
public IReadOnlyList<ExcelQueryBackedTableInfo> GetQueryBackedTables() #

Lists query-backed worksheet tables that have a resolvable native query-table relationship.

Returns

IReadOnlyList<ExcelQueryBackedTableInfo>
public ExcelSheet GetSheet(string name) #

Gets a worksheet by name.

Parameters

name string required

Returns

ExcelSheet
public IReadOnlyList<string> GetSheetNames() #

Returns worksheet names in workbook order.

Returns

IReadOnlyList<string>
public ExcelStreamingContractReport GetStreamingContract() #

Returns a streaming/read-write contract summary for large workbook workflows.

public IReadOnlyList<ExcelTableInfo> GetTables() #

Returns all Excel tables defined in the workbook.

Returns

IReadOnlyList<ExcelTableInfo>
public IReadOnlyList<ExcelPivotInteractionCacheInfo> GetWorkbookSlicerCaches() #

Returns workbook-level slicer cache metadata parts.

Returns

IReadOnlyList<ExcelPivotInteractionCacheInfo>
public ExcelWorkbookThemeInfo GetWorkbookTheme(bool includeXml = false) #

Gets workbook theme metadata and optionally includes the raw theme XML.

Parameters

includeXml bool = false optional
public string? GetWorkbookThemeXml() #

Gets the raw workbook theme XML when a theme part exists.

Returns

string?
public IReadOnlyList<ExcelPivotInteractionCacheInfo> GetWorkbookTimelineCaches() #

Returns workbook-level timeline cache metadata parts.

Returns

IReadOnlyList<ExcelPivotInteractionCacheInfo>
public ExcelWorkbookWriteReservationInfo GetWriteReservation() #

Gets workbook write-reservation metadata. This is separate from workbook protection and package encryption.

ImportSpreadsheetXml 3 overloads
public static OfficeConversionResult<ExcelDocument, ExcelSpreadsheetXmlReport> ImportSpreadsheetXml(string filePath, ExcelSpreadsheetXmlOptions? options = null) #

Imports a bounded XML Spreadsheet 2003 file into the normal editable workbook model. Unsupported features are reported, never evaluated. The caller owns the returned workbook.

Parameters

filePath string required
options OfficeIMO.Excel.ExcelSpreadsheetXmlOptions? = null optional

Returns

OfficeConversionResult<ExcelDocument, ExcelSpreadsheetXmlReport>
public static OfficeConversionResult<ExcelDocument, ExcelSpreadsheetXmlReport> ImportSpreadsheetXml(byte[] input, ExcelSpreadsheetXmlOptions? options = null) #

Imports XML Spreadsheet bytes with operation-level fidelity diagnostics.

Parameters

input byte[] required
options OfficeIMO.Excel.ExcelSpreadsheetXmlOptions? = null optional

Returns

OfficeConversionResult<ExcelDocument, ExcelSpreadsheetXmlReport>
public static OfficeConversionResult<ExcelDocument, ExcelSpreadsheetXmlReport> ImportSpreadsheetXml(Stream input, ExcelSpreadsheetXmlOptions? options = null) #

Imports the remaining bytes of a readable stream. The stream remains open and its position advances. Use ThrowIfLoss on the result when omissions must reject the workflow; dispose its Value even on rejection.

Parameters

input System.IO.Stream required
options OfficeIMO.Excel.ExcelSpreadsheetXmlOptions? = null optional

Returns

OfficeConversionResult<ExcelDocument, ExcelSpreadsheetXmlReport>
public IReadOnlyList<ExcelDataSetImportResult> InsertDataSet(DataSet dataSet, bool createTables = true, ExcelTableStyle tableStyle = TableStyleMedium2, bool includeHeaders = true, bool includeAutoFilter = true, bool autoFit = false, ExcelExecutionMode? mode = null, CancellationToken ct = default) #

Imports a DataSet into the workbook with one worksheet per source DataTable.

Parameters

dataSet System.Data.DataSet required
Source dataset.
createTables bool = true optional
Create an Excel table over each imported DataTable.
tableStyle OfficeIMO.Excel.ExcelTableStyle = TableStyleMedium2 optional
Excel table style to use when createTables is true.
includeHeaders bool = true optional
Write source column names as the first row.
includeAutoFilter bool = true optional
Include table AutoFilter dropdowns when creating tables.
autoFit bool = false optional
Auto-fit imported columns after each sheet is created.
mode OfficeIMO.Excel.ExcelExecutionMode? = null optional
Optional execution mode override for DataTable writes.
ct System.Threading.CancellationToken = default optional
Cancellation token.

Returns

IReadOnlyList<ExcelDataSetImportResult> Import results describing the created worksheets and ranges.
Inspect 2 overloads
public ExcelWorkbookInfo Inspect(ExcelReaderOptions? options = null) #

Creates an immutable workbook snapshot that exposes OfficeIMO's current workbook model for downstream integrations.

Parameters

options OfficeIMO.Excel.ExcelReaderOptions? = null optional
public ExcelWorkbookInfo Inspect(ExcelReaderOptions? options, CancellationToken cancellationToken) #

Creates the native immutable workbook snapshot with cancellation between source sheets, rows and cells.

Parameters

options OfficeIMO.Excel.ExcelReaderOptions? required
cancellationToken System.Threading.CancellationToken required
public ExcelWorkbookCommentReport InspectComments() #

Audits legacy notes and threaded comments across the workbook.

public ExcelDataModelReport InspectDataModel() #

Inspects data model, Power Query, connection, query table, and external link package parts.

public OfficeEmbeddedPayloadInspection InspectEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions? options = null, CancellationToken cancellationToken = default) #

Inventories inert native payloads and creates a bounded cumulative read session. Keep this document open for new reads; returned streams are detached and caller-owned.

Parameters

options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeEmbeddedPayloadInspection
public ExcelFeatureReport InspectFeatures() #

Inspects workbook features and reports which ones OfficeIMO can edit, partially edit, preserve, or does not support yet.

public ExcelFormulaInspection InspectFormulas() #

Inspects formula cells across all worksheets without changing workbook contents.

public OfficeHiddenDataReport InspectHiddenData() #

Finds metadata, personal information and hidden data, the way Office's Document Inspector does, without changing the workbook.

Returns

OfficeHiddenDataReport
public OfficeContentSafetyReport InspectLoadedContentSafety(OfficeContentSafetyOptions? options = null, CancellationToken cancellationToken = default) #

Inspects the currently loaded workbook without reopening, calculating formulas, refreshing links, or saving. Source-load limits remain the caller's responsibility.

Parameters

options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeContentSafetyReport
public ExcelSignatureInfo InspectSignatures() #

Inspects package-level digital-signature metadata without validating cryptographic trust.

InspectTemplate 3 overloads
public ExcelTemplateInspection InspectTemplate() #

Inspects {{Marker}} placeholders across all worksheets without modifying the workbook.

public ExcelTemplateInspection InspectTemplate(IDictionary<string, object?> values) #

Inspects {{Marker}} placeholders across all worksheets and reports which markers are missing from the supplied values.

Parameters

values System.Collections.Generic.IDictionary<string, object?> required
public ExcelTemplateInspection InspectTemplate(object model) #

Inspects {{Marker}} placeholders across all worksheets and reports which markers are missing from public properties on the supplied model.

Parameters

model object required
InspectVbaProject 2 overloads
public OfficeVbaProjectInfo? InspectVbaProject(bool includeSha256 = false) #

Inspects the attached VBA project without executing macro code.

Parameters

includeSha256 bool = false optional

Returns

OfficeVbaProjectInfo?
public OfficeVbaProjectInfo? InspectVbaProject(bool includeSha256, long maxBytes) #

Inspects the attached VBA project while enforcing a decoded byte limit.

Parameters

includeSha256 bool required
maxBytes long required

Returns

OfficeVbaProjectInfo?
public OfficeVbaProjectInfo? InspectVbaProjectMetadata() #

Inventories the VBA part and signature relationship without reading its bytes or decoding module names. Payload length remains unknown.

Returns

OfficeVbaProjectInfo?
public void InvalidateFormulas() #

Marks all formulas dirty so Excel-compatible applications recalculate them on open.

public IReadOnlyList<ExcelNamedRangeInfo> ListNamedRanges(bool includeBuiltIn = true, bool includeHidden = true) #

Returns all workbook and sheet-scoped defined names with scope and hidden metadata.

Parameters

includeBuiltIn bool = true optional
includeHidden bool = true optional

Returns

IReadOnlyList<ExcelNamedRangeInfo>
Load 6 overloads
public static ExcelDocument Load(string filePath, ExcelLoadOptions? options = null) #

Loads an existing Excel document.

Parameters

filePath string required
Path to the file.
options OfficeIMO.Excel.ExcelLoadOptions? = null optional
Access, persistence, and low-level package options.

Returns

ExcelDocument Loaded ExcelDocument instance.
public static ExcelDocument Load(Stream stream, ExcelLoadOptions? options = null) #

Loads an existing Excel document from the provided stream.

Parameters

stream System.IO.Stream required
Input stream containing the workbook package. Editable writable seekable sources become the associated destination; other sources remain detached.
options OfficeIMO.Excel.ExcelLoadOptions? = null optional
Access, persistence, and low-level package options.

Returns

ExcelDocument Loaded ExcelDocument instance.
public static ExcelDocument Load(string path, ExcelLoadOptions? options, out OfficeConversionReport report) #

Loads a workbook and returns findings from its source projection.

Parameters

path string required
options OfficeIMO.Excel.ExcelLoadOptions? required
report OfficeIMO.OfficeConversionReport required
public static ExcelDocument Load(Stream stream, ExcelLoadOptions? options, out OfficeConversionReport report) #

Loads a workbook stream and returns findings from its source projection.

Parameters

stream System.IO.Stream required
options OfficeIMO.Excel.ExcelLoadOptions? required
report OfficeIMO.OfficeConversionReport required
public static ExcelDocument Load(string path, ExcelLoadOptions? options, CancellationToken cancellationToken) #

Loads a workbook with cancellation during native XLSB record projection.

Parameters

path string required
options OfficeIMO.Excel.ExcelLoadOptions? required
cancellationToken System.Threading.CancellationToken required
public static ExcelDocument Load(Stream stream, ExcelLoadOptions? options, CancellationToken cancellationToken) #

Loads a caller-owned stream with cancellation during native XLSB record projection.

Parameters

stream System.IO.Stream required
options OfficeIMO.Excel.ExcelLoadOptions? required
cancellationToken System.Threading.CancellationToken required
LoadAsync 3 overloads
public static async Task<ExcelDocument> LoadAsync(string filePath, ExcelLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously loads an Excel document from the specified path.

Parameters

filePath string required
Path to the Excel file.
options OfficeIMO.Excel.ExcelLoadOptions? = null optional
Access, persistence, and low-level package options.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task<ExcelDocument> Loaded ExcelDocument instance.

Exceptions

  • FileNotFoundException – Thrown when the file does not exist.
public static async Task<ExcelDocument> LoadAsync(Stream stream, ExcelLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously loads an Excel document from the provided stream.

Parameters

stream System.IO.Stream required
Input stream containing the workbook package. Editable writable seekable sources become the associated destination; other sources remain detached.
options OfficeIMO.Excel.ExcelLoadOptions? = null optional
Access, persistence, and low-level package options.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task<ExcelDocument> Loaded ExcelDocument instance.
public static async Task<ExcelDocument> LoadAsync(Uri uri, ExcelLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously loads an Excel workbook from a remote URI.

Parameters

uri System.Uri required
HTTP or HTTPS URI of the workbook.
options OfficeIMO.Excel.ExcelLoadOptions? = null optional
Access, persistence, and low-level package options.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task<ExcelDocument> Loaded ExcelDocument instance.
public ExcelWorkbookMergeResult MergeWorkbookFrom(ExcelDocument sourceDocument, ExcelWorkbookMergeOptions? options = null) #

Imports selected or all worksheets from another workbook into this workbook.

Parameters

sourceDocument OfficeIMO.Excel.ExcelDocument required
options OfficeIMO.Excel.ExcelWorkbookMergeOptions? = null optional
public ExcelWorksheetMergeResult MergeWorksheets(ExcelSheet targetSheet, ExcelSheet sourceSheet, ExcelWorksheetMergeOptions? options = null) #

Merges source worksheet rows into a target worksheet by appending or writing to a requested target position. This is a workbook operation over worksheet values; callers own any data shaping or relational joins before writing.

Parameters

targetSheet OfficeIMO.Excel.ExcelSheet required
sourceSheet OfficeIMO.Excel.ExcelSheet required
options OfficeIMO.Excel.ExcelWorksheetMergeOptions? = null optional
public static string NormalizeDefinedName(string name, ExcelDefinedNameValidationMode mode = Sanitize) #

Ensures a defined name complies with Excel rules. In Sanitize mode, returns a corrected name. Throws in Strict mode when input is invalid. Rules: - 1..255 characters - First char must be a letter, underscore, or backslash - Allowed characters: letters, digits, underscore, period, backslash - Cannot look like a cell reference (e.g., A1, AA10) or an R1C1 reference - Cannot be TRUE or FALSE (case-insensitive)

Parameters

name string required
Authored workbook defined name.
mode OfficeIMO.Excel.ExcelDefinedNameValidationMode = Sanitize optional
Whether invalid names are sanitized or rejected.

Returns

string The exact defined name that can be emitted to the workbook.
public Stream OpenEmbeddedPayload(string id, long maximumBytes, CancellationToken cancellationToken = default) #

Opens a complete bounded read-only detached payload stream. The caller owns its lifetime; no external target is accessed.

Parameters

id string required
maximumBytes long required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Stream
public void OpenInApplication(string? filePath = null) #

Opens the associated workbook in the operating system's registered application.

Parameters

filePath string? = null optional
OpenReader 2 overloads
public static ExcelWorkbookDataReader OpenReader(string path, ExcelReaderOptions? options = null) #

Opens an XLSX, XLSM, XLTX, XLTM, XLAM, XLSB, or BIFF8 XLS workbook as a forward-only data reader. Worksheets are exposed in workbook order through DbDataReader.NextResult.

Parameters

path string required
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
public static ExcelWorkbookDataReader OpenReader(Stream stream, ExcelReaderOptions? options = null) #

Opens an XLSX, XLSM, XLTX, XLTM, XLAM, XLSB, or BIFF8 XLS workbook stream as a forward-only data reader. The format is detected from the package rather than the file name. The input stream remains open after the returned reader is disposed.

Parameters

stream System.IO.Stream required
Readable workbook stream positioned at the workbook bytes to read.
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
Workbook reader options.

Returns

ExcelWorkbookDataReader A forward-only reader whose results follow workbook worksheet order.
OpenReaderAsync 3 overloads
public static async Task<ExcelWorkbookDataReader> OpenReaderAsync(string path, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously reads a local XLSX, XLSM, XLTX, XLTM, XLAM, XLSB, or BIFF8 XLS file and opens it as a forward-only data reader.

Parameters

path string required
Workbook path with a supported Excel extension.
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
Worksheet selection, reader limits, conversion, and cancellation settings.
cancellationToken System.Threading.CancellationToken = default optional
Cancels opening and remains active for the returned reader.

Returns

Task<ExcelWorkbookDataReader> A reader owned by the caller. The input file is closed before this task completes.
public static Task<ExcelWorkbookDataReader> OpenReaderAsync(Stream stream, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously reads the remaining workbook bytes from a stream and opens a forward-only data reader. The physical XLSX, XLSM, XLTX, XLTM, XLAM, XLSB, or BIFF8 XLS format is detected from those bytes.

Parameters

stream System.IO.Stream required
Readable stream positioned at the workbook bytes to read.
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
Worksheet selection, reader limits, conversion, and cancellation settings.
cancellationToken System.Threading.CancellationToken = default optional
Cancels opening and remains active for the returned reader.

Returns

Task<ExcelWorkbookDataReader> A reader owned by the caller.
public static async Task<ExcelWorkbookDataReader> OpenReaderAsync(Uri uri, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Downloads an HTTP or HTTPS workbook and opens it as a forward-only data reader.

Parameters

uri System.Uri required
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public void PreflightWorkbook() #

Performs a safety preflight across all worksheets to reduce the likelihood of Excel prompting for repairs on open. It removes empty containers (Hyperlinks/MergeCells), drops orphaned drawing and header/footer references, and cleans up invalid table references.

public void ProtectWorkbook(ExcelWorkbookProtectionOptions? options = null) #

Protects workbook structure/window metadata. This is not file encryption.

Parameters

options OfficeIMO.Excel.ExcelWorkbookProtectionOptions? = null optional
public OfficeVbaProject? ReadVbaProject(OfficeVbaReadOptions? options = null) #

Reads a detached, editable native VBA project; returns null when no project exists.

Parameters

options OfficeIMO.OfficeVbaReadOptions? = null optional

Returns

OfficeVbaProject?
public int RecalculateSupportedFormulas() #

Evaluates supported formulas and writes cached values.

Returns

int
public async Task<IReadOnlyList<ExcelQueryRefreshResult>> RefreshQueriesAsync(IExcelQueryExecutionHost host, ExcelQueryExecutionPolicy policy, CancellationToken cancellationToken = default) #

Refreshes all query-backed tables sequentially through one explicit caller host and policy.

Parameters

host OfficeIMO.Excel.IExcelQueryExecutionHost required
policy OfficeIMO.Excel.ExcelQueryExecutionPolicy required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<IReadOnlyList<ExcelQueryRefreshResult>>
public async Task<ExcelQueryRefreshResult> RefreshQueryAsync(string connectionOrTableName, IExcelQueryExecutionHost host, ExcelQueryExecutionPolicy policy, CancellationToken cancellationToken = default) #

Executes one query through an explicit caller host and atomically replaces its owned table data.

Parameters

connectionOrTableName string required
host OfficeIMO.Excel.IExcelQueryExecutionHost required
policy OfficeIMO.Excel.ExcelQueryExecutionPolicy required
cancellationToken System.Threading.CancellationToken = default optional
public bool RemoveCustomDocumentProperty(string name) #

Removes a custom workbook property.

Parameters

name string required

Returns

bool
public bool RemoveEmbeddedPayload(string id) #

Removes an embedded payload and known worksheet OLE/control markup that references it.

Parameters

id string required

Returns

bool
public OfficeHiddenDataReport RemoveHiddenData(OfficeHiddenDataOptions? options = null) #

Removes the selected categories of metadata and hidden data, then reports what was found and what happened to each item. Save the workbook to keep the result.

Parameters

options OfficeIMO.OfficeHiddenDataOptions? = null optional
Categories to remove; defaults to OfficeHiddenDataKind.Default, which keeps hidden sheets, rows, columns and names.

Returns

OfficeHiddenDataReport
public void RemoveMacros() #

Removes the complete VBA project.

public bool RemoveNamedRange(string name, ExcelSheet? scope = null, bool save = true) #

Removes a defined name. If scope is provided, removes the sheet‑local name; otherwise the global name.

Parameters

name string required
Defined name to remove.
scope OfficeIMO.Excel.ExcelSheet? = null optional
Optional sheet scope.
save bool = true optional
When true, saves the workbook after removal.

Returns

bool True if the name existed and was removed; otherwise false.
public bool RemoveNamedStyle(string name) #

Removes a custom named-style catalog entry without changing already formatted cells.

Parameters

name string required

Returns

bool
public bool RemovePivotInteraction(string name, bool removeUnusedCache = true) #

Removes one native slicer or timeline view and optionally its unused cache.

Parameters

name string required
removeUnusedCache bool = true optional

Returns

bool
RemoveProvenance 2 overloads
public static OfficeProvenanceRemovalResult RemoveProvenance(string inputPath, string outputPath, OfficeProvenanceRemovalOptions? options = null) #

Removes selected provenance and atomically writes an Open XML workbook.

Parameters

inputPath string required
outputPath string required
options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null optional

Returns

OfficeProvenanceRemovalResult
public static OfficeProvenanceRemovalResult RemoveProvenance(byte[] workbookBytes, string fileName = "workbook.xlsx", OfficeProvenanceRemovalOptions? options = null) #

Removes selected provenance from encoded Open XML workbook bytes.

Parameters

workbookBytes byte[] required
fileName string = "workbook.xlsx" optional
options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null optional

Returns

OfficeProvenanceRemovalResult
public bool RemoveQueryBackedTable(string connectionOrTableName, bool preserveTable = true) #

Detaches a query binding and removes its unused OfficeIMO-owned connection, optionally converting the table to a normal cell range.

Parameters

connectionOrTableName string required
preserveTable bool = true optional

Returns

bool
RemoveSelectedContent 2 overloads
public static OfficeContentCleanupResult RemoveSelectedContent(byte[] workbookBytes, OfficeContentCleanupSelection selection, string fileName = "workbook.xlsx", OfficeContentCleanupOptions? options = null) #

Removes exact selected concealed-content findings and emits the same physical Excel format.

Parameters

workbookBytes byte[] required
selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection required
fileName string = "workbook.xlsx" optional
options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null optional

Returns

OfficeContentCleanupResult
public static OfficeContentCleanupResult RemoveSelectedContent(string inputPath, string outputPath, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null) #

Atomically writes an explicitly cleaned Excel artifact.

Parameters

inputPath string required
outputPath string required
selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection required
options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null optional

Returns

OfficeContentCleanupResult
public void RemoveWorksheet(string sheetName) #

Removes a worksheet by name, deleting its part and entry in the workbook.

Parameters

sheetName string required
public bool RenameNamedRange(string oldName, string newName, ExcelSheet? scope = null, ExcelDefinedNameValidationMode validationMode = Sanitize, bool save = true) #

Renames an existing workbook or sheet-scoped defined name.

Parameters

oldName string required
newName string required
scope OfficeIMO.Excel.ExcelSheet? = null optional
validationMode OfficeIMO.Excel.ExcelDefinedNameValidationMode = Sanitize optional
save bool = true optional

Returns

bool
ReorderWorksheet 2 overloads
public void ReorderWorksheet(string sheetName, int targetIndex) #

Reorders a worksheet by name using a zero-based target index.

Parameters

sheetName string required
targetIndex int required
public void ReorderWorksheet(ExcelSheet sheet, int targetIndex) #

Reorders a worksheet using a zero-based target index.

Parameters

sheet OfficeIMO.Excel.ExcelSheet required
targetIndex int required
public ExcelWorkbookRepairReport RepairWorkbook(ExcelWorkbookRepairOptions? options = null) #

Runs safe workbook repairs using OfficeIMO's existing cleanup engines, then returns before/after diagnostics.

Parameters

options OfficeIMO.Excel.ExcelWorkbookRepairOptions? = null optional
ReplaceEmbeddedPayload 2 overloads
public void ReplaceEmbeddedPayload(string id, byte[] data) #

Replaces an embedded payload while preserving its owner relationship.

Parameters

id string required
data byte[] required
public void ReplaceEmbeddedPayload(string id, Stream stream, long? maxBytes = null) #

Replaces an embedded payload from a readable stream.

Parameters

id string required
stream System.IO.Stream required
maxBytes long? = null optional
public ExcelDocument ResetWorkbookTheme(string? name = null) #

Replaces the workbook theme with the shared default theme.

Parameters

name string? = null optional
public string? ResolveThemeColorArgb(uint themeIndex, double? tint = null) #

Resolves a SpreadsheetML theme color to an ARGB hexadecimal value.

Parameters

themeIndex uint required
Zero-based SpreadsheetML theme index: light 1, dark 1, light 2, dark 2, followed by accent colors 1 through 6.
tint double? = null optional
Optional SpreadsheetML tint between -1 and 1.

Returns

string? An eight-character ARGB value, or null when the theme color cannot be resolved.
public ExcelWorkbookDiagnosticReport RunWorkbookDoctor(ExcelWorkbookDoctorOptions? options = null) #

Runs workbook diagnostics and optional safe repairs for common automation hazards.

Parameters

options OfficeIMO.Excel.ExcelWorkbookDoctorOptions? = null optional
Save 6 overloads
public void Save(string filePath) #

Saves the document without opening it.

Parameters

filePath string required
Path to save to.
public void Save(string filePath, ExcelSaveOptions? options) #

Saves the document with typed options and no positional Boolean.

Parameters

filePath string required
Path to save to.
options OfficeIMO.Excel.ExcelSaveOptions? required
Optional save policy settings.
public void Save() #

Saves the document without opening it.

public void Save(ExcelSaveOptions? options) #

Saves to the associated destination with optional save settings.

Parameters

options OfficeIMO.Excel.ExcelSaveOptions? required
public void Save(Stream destination) #

Saves the document into a writable stream as XLSX.

Parameters

destination System.IO.Stream required
Writable stream that receives the Excel package content.
public void Save(Stream destination, ExcelSaveOptions? options) #

Saves the document into a writable stream with optional robustness options.

Parameters

destination System.IO.Stream required
Writable stream that receives the Excel package content.
options OfficeIMO.Excel.ExcelSaveOptions? required
Optional save behaviors (safe defined-name repair, post-save Open XML validation).
public OfficeConversionReport SaveAsImages(string folderPath, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Saves the selected worksheet images without retaining their encoded payloads, and returns an aggregate report.

Parameters

folderPath string required
options OfficeIMO.Excel.ExcelImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeConversionReport
public async Task<OfficeConversionReport> SaveAsImagesAsync(string folderPath, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously saves the selected worksheet images without retaining payloads, and returns an aggregate report.

Parameters

folderPath string required
options OfficeIMO.Excel.ExcelImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<OfficeConversionReport>
SaveAsync 5 overloads
public Task SaveAsync(Stream destination, CancellationToken cancellationToken = default) #

Asynchronously saves the document into a writable stream.

Parameters

destination System.IO.Stream required
Writable stream that receives the Excel package content.
cancellationToken System.Threading.CancellationToken = default optional
Cancels the asynchronous save work.

Returns

Task
public Task SaveAsync(Stream destination, ExcelSaveOptions? options, CancellationToken cancellationToken = default) #

Asynchronously saves the document into a writable stream with optional robustness options.

Parameters

destination System.IO.Stream required
Writable stream that receives the Excel package content.
options OfficeIMO.Excel.ExcelSaveOptions? required
Optional save behaviors (safe defined-name repair, post-save Open XML validation).
cancellationToken System.Threading.CancellationToken = default optional
Cancels the asynchronous save work.

Returns

Task
public Task SaveAsync(CancellationToken cancellationToken = default) #

Asynchronously saves the document.

Parameters

cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task
public Task SaveAsync(ExcelSaveOptions? options, CancellationToken cancellationToken = default) #

Asynchronously saves to the associated destination with optional save settings.

Parameters

options OfficeIMO.Excel.ExcelSaveOptions? required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public Task SaveAsync(string filePath, ExcelSaveOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously saves to a path with optional save settings.

Parameters

filePath string required
options OfficeIMO.Excel.ExcelSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public void SaveCopy(string filePath, ExcelSaveOptions? options = null) #

Saves an independent copy without changing this workbook's associated destination.

Parameters

filePath string required
Destination XLSX, XLSM, XLTX, XLTM, XLAM, XLS, or XLSB path.
options OfficeIMO.Excel.ExcelSaveOptions? = null optional
Optional save policy settings.
public async Task SaveCopyAsync(string filePath, ExcelSaveOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously saves an independent copy without changing this workbook's associated destination.

Parameters

filePath string required
options OfficeIMO.Excel.ExcelSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public void SaveEmbeddedPayload(string id, string filePath, long? maxBytes = null) #

Saves an embedded payload by its package-local id.

Parameters

id string required
filePath string required
maxBytes long? = null optional
public void SaveMacros(string filePath, long? maxBytes = null) #

Saves the VBA project when one is present.

Parameters

filePath string required
maxBytes long? = null optional
public IReadOnlyList<ExcelFormulaCellInfo> SearchFormulas(ExcelFormulaSearchOptions options) #

Searches formula text, function calls, or parsed references across the workbook.

Parameters

options OfficeIMO.Excel.ExcelFormulaSearchOptions required

Returns

IReadOnlyList<ExcelFormulaCellInfo>
SetActiveWorksheet 3 overloads
public void SetActiveWorksheet(string sheetName) #

Sets the worksheet that spreadsheet applications should show when the workbook opens.

Parameters

sheetName string required
Worksheet name.
public void SetActiveWorksheet(int sheetIndex) #

Sets the worksheet that spreadsheet applications should show when the workbook opens.

Parameters

sheetIndex int required
Zero-based worksheet index.
public void SetActiveWorksheet(ExcelSheet sheet) #

Sets the worksheet that spreadsheet applications should show when the workbook opens.

Parameters

sheet OfficeIMO.Excel.ExcelSheet required
Worksheet to activate.
SetCustomDocumentProperty 2 overloads
public void SetCustomDocumentProperty(string name, ExcelCustomProperty property) #

Sets or replaces a custom workbook property.

Parameters

name string required
property OfficeIMO.Excel.ExcelCustomProperty required
public void SetCustomDocumentProperty(string name, object? value) #

Sets or replaces a custom workbook property, inferring the custom property type from the value.

Parameters

name string required
value object? required
public void SetNamedFormula(string name, string formula, ExcelSheet? scope = null, bool save = true, bool hidden = false, ExcelDefinedNameValidationMode validationMode = Sanitize) #

Creates or replaces a workbook or worksheet-scoped formula definition.

Parameters

name string required
The defined name used by worksheet formulas.
formula string required
An Excel expression, with or without a leading equals sign.
scope OfficeIMO.Excel.ExcelSheet? = null optional
The worksheet scope, or null for a workbook name.
save bool = true optional
Whether to persist the workbook change immediately.
hidden bool = false optional
Whether Excel hides the name from its normal name list.
validationMode OfficeIMO.Excel.ExcelDefinedNameValidationMode = Sanitize optional
How the defined name is validated or sanitized.
public void SetNamedRange(string name, string range, ExcelSheet? scope = null, bool save = true, bool hidden = false, ExcelDefinedNameValidationMode validationMode = Sanitize) #

Creates or updates a defined name pointing to an A1 range. When scope is provided, the name is local to that sheet; otherwise it is workbook‑global.

Parameters

name string required
Defined name to create or update.
range string required
A1 range (e.g. "A1:B10"). Can include a sheet prefix.
scope OfficeIMO.Excel.ExcelSheet? = null optional
Optional sheet scope for a local name.
save bool = true optional
When true, saves the workbook after the change.
hidden bool = false optional
When true, marks the defined name as hidden.
validationMode OfficeIMO.Excel.ExcelDefinedNameValidationMode = Sanitize optional
Controls how the name and range are validated: Sanitize (default) clamps/adjusts; Strict throws on invalid input.
public ExcelRefreshOnOpenResult SetRefreshOnOpen(bool enabled = true, bool pivotTables = true, bool connections = true, bool? savePivotSourceData = null) #

Enables or disables workbook refresh-on-open metadata for supported workbook data features. OfficeIMO writes the metadata request; Excel-compatible applications perform the actual refresh on open.

Parameters

enabled bool = true optional
Whether refresh-on-open should be enabled.
pivotTables bool = true optional
Update pivot cache definitions.
connections bool = true optional
Update workbook connection metadata parts.
savePivotSourceData bool? = null optional
Optional pivot cache source-data setting to apply together with the refresh request.

Returns

ExcelRefreshOnOpenResult Counts of metadata entries updated.
public void SetVbaProject(OfficeVbaProject project, OfficeVbaWriteOptions? options = null) #

Applies a native source project, preserving unrelated payloads and requiring explicit VBA signature removal.

Parameters

project OfficeIMO.OfficeVbaProject required
options OfficeIMO.OfficeVbaWriteOptions? = null optional
public ExcelDocument SetWorkbookThemeName(string name) #

Sets the workbook theme name while preserving the rest of the theme XML.

Parameters

name string required
public ExcelDocument SetWorkbookThemeXml(string themeXml) #

Replaces or creates the workbook theme part with caller-supplied DrawingML theme XML.

Parameters

themeXml string required
public void SetWriteReservation(ExcelWorkbookWriteReservationOptions? options = null) #

Writes workbook write-reservation metadata. This is not package encryption and does not protect worksheet or workbook structure.

Parameters

options OfficeIMO.Excel.ExcelWorkbookWriteReservationOptions? = null optional
public static OfficePackageSigningResult SignPackageSignature(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions? options = null) #

Creates and validates an OPC signature in a saved XLSX/XLSM package.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficePackageSigningOptions? = null optional

Returns

OfficePackageSigningResult
public static OfficeVbaSigningResult SignVbaProject(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions? options = null, IEnumerable<X509Certificate2>? certificateChain = null) #

Creates and atomically validates legacy, agile, and V3 VBA signatures.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficeVbaSigningOptions? = null optional
certificateChain System.Collections.Generic.IEnumerable<System.Security.Cryptography.X509Certificates.X509Certificate2>? = null optional

Returns

OfficeVbaSigningResult
public byte[] ToBytes(ExcelSaveOptions? options = null) #

Encodes the workbook using one native-output options bag.

Parameters

options OfficeIMO.Excel.ExcelSaveOptions? = null optional

Returns

byte[]
ToImages 3 overloads
public IReadOnlyList<OfficeImageExportResult> ToImages(ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Renders a batch using the encoding and selection in the options.

Parameters

options OfficeIMO.Excel.ExcelImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IReadOnlyList<OfficeImageExportResult>
public IReadOnlyList<OfficeImageExportResult> ToImages(OfficeImageExportFormat format, ExcelImageExportOptions? options = null) #

Exports workbook sheets as supported raster formats or SVG images.

Parameters

format OfficeIMO.Drawing.OfficeImageExportFormat required
options OfficeIMO.Excel.ExcelImageExportOptions? = null optional

Returns

IReadOnlyList<OfficeImageExportResult>
public void ToImages(OfficeImageExportFormat format, OfficeImageExportConsumer consumer, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Streams workbook images to a consumer without retaining earlier payloads.

Parameters

format OfficeIMO.Drawing.OfficeImageExportFormat required
consumer OfficeIMO.Drawing.OfficeImageExportConsumer required
options OfficeIMO.Excel.ExcelImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public Task<IReadOnlyList<OfficeImageExportResult>> ToImagesAsync(ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Renders a batch asynchronously using the same options and evidence contract.

Parameters

options OfficeIMO.Excel.ExcelImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<IReadOnlyList<OfficeImageExportResult>>
public bool TryGetCompatibilitySourcePayload(out OfficeCompatibilitySourcePayload? payload, out string? error) #

Tries to read an original source retained by a compatibility conversion.

Parameters

payload OfficeIMO.OfficeCompatibilitySourcePayload? required
error string? required

Returns

bool
public bool TryGetSheet(string name, out ExcelSheet? sheet) #

Tries to get a worksheet by name.

Parameters

name string required
sheet OfficeIMO.Excel.ExcelSheet? required

Returns

bool
public static OfficePackageSigningResult TrySignPackageSignature(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions? options = null) #

Attempts OPC signature creation without throwing for an ordinary signing failure.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficePackageSigningOptions? = null optional

Returns

OfficePackageSigningResult
public static OfficeVbaSigningResult TrySignVbaProject(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions? options = null, IEnumerable<X509Certificate2>? certificateChain = null) #

Attempts atomic VBA signing and returns structured failure evidence.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficeVbaSigningOptions? = null optional
certificateChain System.Collections.Generic.IEnumerable<System.Security.Cryptography.X509Certificates.X509Certificate2>? = null optional

Returns

OfficeVbaSigningResult
public void UnprotectWorkbook(bool structure = true, bool windows = true) #

Removes the selected workbook structure/window restrictions. With both selected (the default), removes all workbook protection metadata. A subset preserves other restrictions and password hashes.

Parameters

structure bool = true optional
Whether to remove the workbook structure restriction.
windows bool = true optional
Whether to remove the workbook window restriction.
public List<OfficeOpenXmlValidationError> ValidateDocument(OfficeOpenXmlFileFormatVersion fileFormatVersion = Microsoft365) #

Validates the document using the specified file format version.

Parameters

fileFormatVersion OfficeIMO.OfficeOpenXmlFileFormatVersion = Microsoft365 optional
File format version to validate against.

Returns

List<OfficeOpenXmlValidationError> List of validation errors.
public IReadOnlyList<string> ValidateOpenXml() #

Validates the current spreadsheet with Open XML validator and returns error messages (if any). Useful for troubleshooting "Repaired Records" issues in Excel.

Returns

IReadOnlyList<string>
ValidatePackageSignatures 2 overloads
public static OfficePackageSignatureValidationReport ValidatePackageSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficePackageSignatureValidationOptions? options = null) #

Validates a saved XLSX/XLSM package through an explicitly supplied security provider.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
options OfficeIMO.Security.OfficePackageSignatureValidationOptions? = null optional

Returns

OfficePackageSignatureValidationReport
public static OfficePackageSignatureValidationReport ValidatePackageSignatures(Stream source, IOfficeSecurityProvider securityProvider, OfficePackageSignatureValidationOptions? options = null) #

Validates an encoded XLSX/XLSM package from a caller-owned stream.

Parameters

source System.IO.Stream required
A readable stream containing the original package bytes.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
The provider used for cryptographic and certificate validation.
options OfficeIMO.Security.OfficePackageSignatureValidationOptions? = null optional
Signature validation policy and resource limits, or null for defaults.

Returns

OfficePackageSignatureValidationReport The package signature validation results.
ValidateTemplateBindings 2 overloads
public ExcelTemplateBindingReport ValidateTemplateBindings(IDictionary<string, object?> values) #

Validates all workbook template markers against a dictionary of values before applying the template.

Parameters

values System.Collections.Generic.IDictionary<string, object?> required
public ExcelTemplateBindingReport ValidateTemplateBindings(object model) #

Validates all workbook template markers against an object model before applying the template.

Parameters

model object required
public static OfficeVbaSignatureValidationResult ValidateVbaSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficeVbaSignatureInspectionOptions? options = null) #

Validates VBA CMS, trust, timestamp, and Office SIP content binding.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
options OfficeIMO.Security.OfficeVbaSignatureInspectionOptions? = null optional

Returns

OfficeVbaSignatureValidationResult

Properties

public int ActiveWorksheetIndex { get; } #

Gets the zero-based index of the worksheet that spreadsheet applications show when the workbook opens.

public ExcelSheet? ActiveWorksheet { get; } #

Gets the worksheet that spreadsheet applications show when the workbook opens, or null when the active tab is not a worksheet.

public ExcelCalculationOptions Calculation { get; } #

Formula calculation and cached-result policy used during save.

public bool IsWorkbookProtected { get; } #

Returns true when workbook-level structure or window protection is present.

public bool SheetCachingEnabled { get; set; } #

Enables caching of ExcelSheet wrappers for faster repeat access at the cost of higher memory usage. Set to false to avoid holding references to every sheet in very large workbooks.

public IEqualityComparer<string> TableNameComparer { get; set; } #

Controls how workbook-level table name uniqueness is compared. Defaults to StringComparer.OrdinalIgnoreCase. Changing this will reset the internal cache and rebuild it on next use. Set it once before adding tables for predictable behavior.

public ExcelChartStylePreset? DefaultChartStylePreset { get; set; } #

Optional default chart style preset applied to charts created in this workbook.

public ExcelExecutionPolicy Execution { get; } #

Execution policy for controlling parallel vs sequential operations.

public Func<DateTimeOffset, DateTime> DateTimeOffsetWriteStrategy { get; set; } #

Controls how DateTimeOffset values are converted to DateTime before being written to worksheet cells. Defaults to DateTimeOffset.LocalDateTime.

public IReadOnlyList<ExcelSheet> Sheets { get; } #

Gets a list of worksheets contained in the document.

public SpreadsheetDocument OpenXmlDocument { get; } #

Gets the underlying Open XML package for advanced integration scenarios.

public ExcelDateSystem DateSystem { get; set; } #

Gets or sets the workbook date system used for serialized date values.

public string? FilePath { get; internal set; } #

Path to the file backing this document.

public ExcelBuiltinDocumentProperties Properties { get; internal set; } #

Built-in (core) document properties (Title, Creator, etc.).

public ExcelApplicationProperties ApplicationProperties { get; internal set; } #

Extended (application) properties (Company, Manager, etc.).

public ExcelCustomDocumentPropertyCollection CustomProperties { get; } #

Custom workbook properties keyed by property name.

public FileAccess FileOpenAccess { get; } #

FileOpenAccess of the document

public DocumentAccessMode AccessMode { get; } #

Gets whether the workbook was loaded for reading or editing.

public DocumentPersistenceMode PersistenceMode { get; } #

Gets the persistence policy selected when the workbook was created or loaded.

public bool DocumentIsValid { get; } #

Indicates whether the document is valid.

public List<OfficeOpenXmlValidationError> DocumentValidationErrors { get; } #

Gets the list of validation errors for the document.

public bool UsesFileBackedPackage { get; } #

True when the editable Open XML package is staged in a bounded temporary file instead of a byte array.

public ExcelSheet this[string sheetName] { get; } #

Gets a worksheet by name (case-insensitive).

Parameters

sheetName string required
public ExcelSheet this[int sheetIndex] { get; } #

Gets a worksheet by 0-based index in workbook order.

Parameters

sheetIndex int required
public OfficePackageSecurityReport? SourcePackageSecurityReport { get; private set; } #

Structural observations captured from the exact loader source bytes when requested; subsequent edits do not change this source report.

public string? SourcePackageSecurityScope { get; private set; } #

Identifies the physical source scope of captured package observations.

public ExcelFileFormat SourceFormat { get; private set; } #

Gets the detected physical format of the workbook source.

public OfficeFormatDescriptor SourceFormatDescriptor { get; } #

Gets the concrete source format, including modern template, add-in, macro, and XLSB variants.

public string? SourcePath { get; } #

Gets the original legacy source path, or the current Open XML file association.

public IReadOnlyList<XlsbImportDiagnostic> XlsbImportDiagnostics { get; } #

Gets diagnostics produced while importing an XLSB source.

public IReadOnlyList<XlsbPreservedRecordInfo> XlsbPreservedRecords { get; } #

Gets BIFF12 records retained from the XLSB source but not projected into the normal workbook model.

public IReadOnlyList<LegacyXlsImportDiagnostic> LegacyXlsImportDiagnostics { get; } #

Gets diagnostics produced while importing a legacy binary XLS source through normal loading.

public IReadOnlyList<LegacyXlsUnsupportedFeature> LegacyXlsUnsupportedFeatures { get; } #

Gets unsupported or preserve-only legacy XLS features discovered during normal loading.

public IReadOnlyList<LegacyXlsPreservedFeatureRecord> LegacyXlsPreservedFeatures { get; } #

Gets preserve-only BIFF feature records that were not projected into the normal workbook model.

public IReadOnlyList<LegacyXlsUnsupportedSheet> LegacyXlsUnsupportedSheets { get; } #

Gets legacy XLS sheet entries that were discovered but not projected as normal worksheets.

public IReadOnlyList<LegacyXlsChartSheet> LegacyXlsChartSheets { get; } #

Gets legacy XLS chart sheets decoded during import and projected as chart-sheet package parts.

public IReadOnlyList<LegacyXlsCompoundFeatureRecord> LegacyXlsCompoundFeatures { get; } #

Gets legacy XLS compound-container features decoded during import but not projected into the normal workbook package.

public bool HasMacros { get; } #

Indicates whether the workbook contains a VBA project.

Fields

public const int MaximumDefinedNameLength #

Maximum length supported by an Excel workbook defined name.

Value: 255

Extension Methods

RowsAsParallel``1 3 overloads
public static IEnumerable<T> RowsAsParallel<T>(ExcelDocument document, ParallelRowMappingOptions? parallelOptions = null, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Projects rows in bounded parallel batches, preserving source order.

Type Parameters

T

Parameters

document OfficeIMO.Excel.ExcelDocument required
parallelOptions OfficeIMO.Data.ParallelRowMappingOptions? = null optional
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IEnumerable<T>
public static IEnumerable<T?> RowsAsParallel<T>(ExcelDocument document, Action<RowMapper<T?>> configure, ParallelRowMappingOptions? parallelOptions = null, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Projects rows in bounded parallel batches, preserving source order.

Type Parameters

T

Parameters

document OfficeIMO.Excel.ExcelDocument required
configure System.Action<OfficeIMO.Data.RowMapper<T?>> required
parallelOptions OfficeIMO.Data.ParallelRowMappingOptions? = null optional
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IEnumerable<T?>
public static IEnumerable<T?> RowsAsParallel<T>(ExcelDocument document, Func<IDataRecord, T?> factory, ParallelRowMappingOptions? parallelOptions = null, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Projects rows in bounded parallel batches, preserving source order.

Type Parameters

T

Parameters

document OfficeIMO.Excel.ExcelDocument required
factory System.Func<System.Data.IDataRecord, T?> required
parallelOptions OfficeIMO.Data.ParallelRowMappingOptions? = null optional
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IEnumerable<T?>
RowsAs``1 3 overloads
public static IEnumerable<T?> RowsAs<T>(ExcelDocument document, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Projects rows through the shared data-reader mapping contract.

Type Parameters

T

Parameters

document OfficeIMO.Excel.ExcelDocument required
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IEnumerable<T?>
public static IEnumerable<T?> RowsAs<T>(ExcelDocument document, Action<RowMapper<T?>> configure, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Projects rows through the shared data-reader mapping contract.

Type Parameters

T

Parameters

document OfficeIMO.Excel.ExcelDocument required
configure System.Action<OfficeIMO.Data.RowMapper<T?>> required
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IEnumerable<T?>
public static IEnumerable<T?> RowsAs<T>(ExcelDocument document, Func<IDataRecord, T?> factory, ExcelReaderOptions? options = null, CancellationToken cancellationToken = default) #

Projects rows through the shared data-reader mapping contract.

Type Parameters

T

Parameters

document OfficeIMO.Excel.ExcelDocument required
factory System.Func<System.Data.IDataRecord, T?> required
options OfficeIMO.Excel.ExcelReaderOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IEnumerable<T?>