# ExcelDocumentScope

Edits one ExcelDocument: its fluent methods and keywords, each returning this scope.

Class 

`OfficeIMO.Excel`

**Namespace**

`OfficeIMO.Excel`

**Assembly**

`OfficeIMO.Excel`

**Modifiers**

sealed

Edits one [ExcelDocument](/api/excel/officeimo-excel-exceldocument/): its fluent methods and keywords, each returning this scope.

## Inheritance

- object
- ExcelDocumentScope

## Usage

Explore 19 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.

### Returned or exposed by 18

- Method [ExcelDocumentScope.ActiveWorksheet](/api/excel/officeimo-excel-exceldocumentscope/#method-activeworksheet-string)
- Method [ExcelDocumentScope.ApplicationProperties](/api/excel/officeimo-excel-exceldocumentscope/#method-applicationproperties-action-officeimo-excel-excelapplicationproperties)
- Method [ExcelDocumentScope.Calculation](/api/excel/officeimo-excel-exceldocumentscope/#method-calculation-action-officeimo-excel-excelcalculationoptions)
- Method [ExcelDocumentScope.Configure](/api/excel/officeimo-excel-exceldocumentscope/#method-configure-action-officeimo-excel-exceldocument)
- Method [ExcelDocumentScope.CustomProperties](/api/excel/officeimo-excel-exceldocumentscope/#method-customproperties-action-officeimo-excel-excelcustomdocumentpropertycollection)
- Method [ExcelDocumentScope.DateSystem](/api/excel/officeimo-excel-exceldocumentscope/#method-datesystem-officeimo-excel-exceldatesystem)
- Method [ExcelDocumentScope.DateTimeOffsetWriteMode](/api/excel/officeimo-excel-exceldocumentscope/#method-datetimeoffsetwritemode-officeimo-excel-exceldatetimeoffsetwritemode)
- Method [ExcelDocumentScope.DefaultChartStylePreset](/api/excel/officeimo-excel-exceldocumentscope/#method-defaultchartstylepreset-officeimo-excel-excelchartstylepreset)
- Method [ExcelDocumentScope.Execution](/api/excel/officeimo-excel-exceldocumentscope/#method-execution-action-officeimo-excel-excelexecutionpolicy)
- Method [ExcelDocumentScope.Properties](/api/excel/officeimo-excel-exceldocumentscope/#method-properties-action-officeimo-excel-excelbuiltindocumentproperties)
- Method [ExcelDocumentScope.Sheet](/api/excel/officeimo-excel-exceldocumentscope/#method-sheet-string-officeimo-excel-excelsheetnamevalidationmode-action-officeimo-excel-excelsheetscope)
- Method [ExcelDocumentScope.SheetCachingEnabled](/api/excel/officeimo-excel-exceldocumentscope/#method-sheetcachingenabled-boolean)
- Method [ExcelDocumentScope.TableNameComparer](/api/excel/officeimo-excel-exceldocumentscope/#method-tablenamecomparer-collections-generic-iequalitycomparer-system-string)
- Method [ExcelDocumentScope.TableOfContents](/api/excel/officeimo-excel-exceldocumentscope/#method-tableofcontents-string-boolean-boolean-boolean-boolean-predicate-system-string-boolean-action-officeimo-excel-excelsheetscope)
- Method [ExcelDocumentScope.VbaProject](/api/excel/officeimo-excel-exceldocumentscope/#method-vbaproject-officeimo-officevbaproject-officeimo-officevbawriteoptions)
- Method [ExcelDocumentScope.WorkbookThemeName](/api/excel/officeimo-excel-exceldocumentscope/#method-workbookthemename-string)
- Method [ExcelDocumentScope.WorkbookThemeXml](/api/excel/officeimo-excel-exceldocumentscope/#method-workbookthemexml-string)
- Method [ExcelDocumentScope.WriteReservation](/api/excel/officeimo-excel-exceldocumentscope/#method-writereservation-officeimo-excel-excelworkbookwritereservationoptions)

### Accepted by parameters 1

- Method [ExcelDocument.Create](/api/excel/officeimo-excel-exceldocument/#method-create-string-action-officeimo-excel-exceldocumentscope-officeimo-excel-excelcreateoptions) parameter `compose`

Filter members 

Show inherited

## Methods

ActiveWorksheet 4 overloads

`public ExcelDocumentScope ActiveWorksheet(string sheetName)` [#](#method-activeworksheet-string)

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

Parameters

**sheetName string required**

Worksheet name.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope ActiveWorksheet(int sheetIndex)` [#](#method-activeworksheet-int32)

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

Parameters

**sheetIndex int required**

Zero-based worksheet index.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope ActiveWorksheet(ExcelSheet sheet)` [#](#method-activeworksheet-officeimo-excel-excelsheet)

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

Parameters

**sheet OfficeIMO.Excel.ExcelSheet required**

Worksheet to activate.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope ActiveWorksheet(Action<ExcelSheet> configure)` [#](#method-activeworksheet-action-officeimo-excel-excelsheet)

Configures [ExcelDocument.ActiveWorksheet](/api/excel/officeimo-excel-exceldocument/) in place: Gets the worksheet that spreadsheet applications show when the workbook opens, or null when the active tab is not a worksheet.

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelSheet> required**

Configures the value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope ApplicationProperties(Action<ExcelApplicationProperties> configure)` [#](#method-applicationproperties-action-officeimo-excel-excelapplicationproperties)

Configures [ExcelDocument.ApplicationProperties](/api/excel/officeimo-excel-exceldocument/) in place: Extended (application) properties (Company, Manager, etc.).

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelApplicationProperties> required**

Configures the value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope Calculation(Action<ExcelCalculationOptions> configure)` [#](#method-calculation-action-officeimo-excel-excelcalculationoptions)

Configures [ExcelDocument.Calculation](/api/excel/officeimo-excel-exceldocument/) in place: Formula calculation and cached-result policy used during save.

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelCalculationOptions> required**

Configures the value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope Configure(Action<ExcelDocument> configure)` [#](#method-configure-action-officeimo-excel-exceldocument)

Assigns callbacks and related configuration without invoking delegate-valued properties.

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelDocument> required**

Assignments applied in order.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope CustomProperties(Action<ExcelCustomDocumentPropertyCollection> configure)` [#](#method-customproperties-action-officeimo-excel-excelcustomdocumentpropertycollection)

Configures [ExcelDocument.CustomProperties](/api/excel/officeimo-excel-exceldocument/) in place: Custom workbook properties keyed by property name.

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelCustomDocumentPropertyCollection> required**

Configures the value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope DateSystem(ExcelDateSystem value)` [#](#method-datesystem-officeimo-excel-exceldatesystem)

Sets [ExcelDocument.DateSystem](/api/excel/officeimo-excel-exceldocument/): Gets or sets the workbook date system used for serialized date values.

Parameters

**value OfficeIMO.Excel.ExcelDateSystem required**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope DateTimeOffsetWriteMode(ExcelDateTimeOffsetWriteMode value)` [#](#method-datetimeoffsetwritemode-officeimo-excel-exceldatetimeoffsetwritemode)

Sets [ExcelDocument.DateTimeOffsetWriteMode](/api/excel/officeimo-excel-exceldocument/): Controls how DateTimeOffset values are written to worksheet cells. Defaults to [ExcelDateTimeOffsetWriteMode.Text](/api/excel/officeimo-excel-exceldatetimeoffsetwritemode/), which writes ISO 8601 text and keeps the offset. [ExcelDateTimeOffsetWriteMode.Serial](/api/excel/officeimo-excel-exceldatetimeoffsetwritemode/) writes date serials converted by [ExcelDocument.DateTimeOffsetWriteStrategy](/api/excel/officeimo-excel-exceldocument/).

Parameters

**value OfficeIMO.Excel.ExcelDateTimeOffsetWriteMode required**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope DefaultChartStylePreset(ExcelChartStylePreset? value)` [#](#method-defaultchartstylepreset-officeimo-excel-excelchartstylepreset)

Sets [ExcelDocument.DefaultChartStylePreset](/api/excel/officeimo-excel-exceldocument/): Optional default chart style preset applied to charts created in this workbook.

Parameters

**value OfficeIMO.Excel.ExcelChartStylePreset? required**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope Execution(Action<ExcelExecutionPolicy> configure)` [#](#method-execution-action-officeimo-excel-excelexecutionpolicy)

Configures [ExcelDocument.Execution](/api/excel/officeimo-excel-exceldocument/) in place: Execution policy for controlling parallel vs sequential operations.

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelExecutionPolicy> required**

Configures the value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope Properties(Action<ExcelBuiltinDocumentProperties> configure)` [#](#method-properties-action-officeimo-excel-excelbuiltindocumentproperties)

Configures [ExcelDocument.Properties](/api/excel/officeimo-excel-exceldocument/) in place: Built-in (core) document properties (Title, Creator, etc.).

Parameters

**configure System.Action<OfficeIMO.Excel.ExcelBuiltinDocumentProperties> required**

Configures the value.

Returns

`ExcelDocumentScope` The same scope.

Sheet 2 overloads

`public ExcelDocumentScope Sheet(string worksheetName = "", Action<ExcelSheetScope>? configure = null)` [#](#method-sheet-string-action-officeimo-excel-excelsheetscope)

Adds a worksheet to the document.

Parameters

**worksheetName string = "" optional**

Worksheet name.

**configure System.Action<OfficeIMO.Excel.ExcelSheetScope>? = null optional**

Configures the new item through its scope.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope Sheet(string worksheetName, ExcelSheetNameValidationMode validationMode, Action<ExcelSheetScope>? configure = null)` [#](#method-sheet-string-officeimo-excel-excelsheetnamevalidationmode-action-officeimo-excel-excelsheetscope)

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).

**configure System.Action<OfficeIMO.Excel.ExcelSheetScope>? = null optional**

Configures the new item through its scope.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope SheetCachingEnabled(bool value = true)` [#](#method-sheetcachingenabled-boolean)

Sets [ExcelDocument.SheetCachingEnabled](/api/excel/officeimo-excel-exceldocument/): Enables caching of [ExcelSheet](/api/excel/officeimo-excel-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.

Parameters

**value bool = true optional**

The value; true when omitted.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope TableNameComparer(IEqualityComparer<string> value)` [#](#method-tablenamecomparer-collections-generic-iequalitycomparer-system-string)

Sets [ExcelDocument.TableNameComparer](/api/excel/officeimo-excel-exceldocument/): 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.

Parameters

**value System.Collections.Generic.IEqualityComparer<string> required**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope TableOfContents(string sheetName = "TOC", bool placeFirst = true, bool withHyperlinks = true, bool includeNamedRanges = false, bool includeHiddenNamedRanges = false, Predicate<string>? rangeNameFilter = null, bool styled = true, Action<ExcelSheetScope>? configure = null)` [#](#method-tableofcontents-string-boolean-boolean-boolean-boolean-predicate-system-string-boolean-action-officeimo-excel-excelsheetscope)

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.

**configure System.Action<OfficeIMO.Excel.ExcelSheetScope>? = null optional**

Configures the new item through its scope.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope VbaProject(OfficeVbaProject project, OfficeVbaWriteOptions? options = null)` [#](#method-vbaproject-officeimo-officevbaproject-officeimo-officevbawriteoptions)

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

Parameters

**project OfficeIMO.OfficeVbaProject required**

The value.

**options OfficeIMO.OfficeVbaWriteOptions? = null optional**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope WorkbookThemeName(string name)` [#](#method-workbookthemename-string)

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

Parameters

**name string required**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope WorkbookThemeXml(string themeXml)` [#](#method-workbookthemexml-string)

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

Parameters

**themeXml string required**

The value.

Returns

`ExcelDocumentScope` The same scope.

`public ExcelDocumentScope WriteReservation(ExcelWorkbookWriteReservationOptions? options = null)` [#](#method-writereservation-officeimo-excel-excelworkbookwritereservationoptions)

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**

The value.

Returns

`ExcelDocumentScope` The same scope.

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public ExcelDocument Model { get; }` [#](#property-model)

The [ExcelDocument](/api/excel/officeimo-excel-exceldocument/) this scope edits, for plain C# inside a lambda.

<!-- PowerForge markdown artifact sha256:57A85510E19B809FD5A2E65115AC3C792B633E39CBC231236E551A832A42C19C -->
