Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

ExcelSheetScope

OfficeIMO.Excel

Namespace
OfficeIMO.Excel
Assembly
OfficeIMO.Excel
Source revision
22fb5b2be3d2 with working tree changes
Modifiers
sealed

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

Inheritance

  • object
  • ExcelSheetScope

Usage

Explore 23 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 2

Methods

Cell 4 overloads
public ExcelSheetScope Cell(string reference, object? value) #

Writes a value to the cell at reference.

Parameters

reference string required
A1 reference of the cell.
value object? required
Value to write; numbers, dates and booleans keep their type.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Cell(int row, int column, object? value) #

Writes a value to the cell at row and column.

Parameters

row int required
One-based row.
column int required
One-based column.
value object? required
Value to write; numbers, dates and booleans keep their type.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Cell(int row, int column, Action<ExcelCellScope>? configure = null) #

Returns the cell at a 1-based row and column. The handle is a view over the worksheet and stores no cell state, so creating one allocates nothing and does not create the cell until a value or style is written.

Parameters

row int required
The value.
column int required
The value.
configure System.Action<OfficeIMO.Excel.ExcelCellScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Cell(string reference, Action<ExcelCellScope>? configure = null) #

Returns the cell at an A1 reference on this worksheet, such as B7 or $B$7.

Parameters

reference string required
The value.
configure System.Action<OfficeIMO.Excel.ExcelCellScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
Chart 4 overloads
public ExcelSheetScope Chart(OfficeChartType type, ExcelChartData data, OfficeChartOptions? options = null, Action<ExcelChartScope>? configure = null) #

Adds an editable native chart with per-series chart kinds, axes, styles and optional explicit X values.

Parameters

type OfficeIMO.OfficeChartType required
The value.
data OfficeIMO.Excel.ExcelChartData required
The value.
options OfficeIMO.OfficeChartOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelChartScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Chart(OfficeChartType type, ExcelChartDataRange data, OfficeChartOptions? options = null, Action<ExcelChartScope>? configure = null) #

Adds an editable chart linked to a worksheet range, including horizontal ranges and ranges on other sheets.

Parameters

type OfficeIMO.OfficeChartType required
The value.
data OfficeIMO.Excel.ExcelChartDataRange required
The value.
options OfficeIMO.OfficeChartOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelChartScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Chart(OfficeChartType type, string rangeOrTable, OfficeChartOptions? options = null, Action<ExcelChartScope>? configure = null) #

Adds an editable chart linked to an A1 range or a native table on this worksheet.

Parameters

type OfficeIMO.OfficeChartType required
The value.
rangeOrTable string required
The value.
options OfficeIMO.OfficeChartOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelChartScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Chart(OfficeChartType chartKind, OfficeChartData data, OfficeChartOptions? options = null, Action<ExcelChartScope>? configure = null) #

Adds a native Excel chart from the shared OfficeIMO chart contract, including per-series combo kinds and primary or secondary axis assignments.

Parameters

chartKind OfficeIMO.OfficeChartType required
The value.
data OfficeIMO.Drawing.OfficeChartData required
The value.
options OfficeIMO.OfficeChartOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelChartScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope ColumnWidths(IReadOnlyDictionary<int, ExcelColumnWidth> columnWidths) #

Applies positive custom widths together and saves the worksheet XML once. Existing column styles, visibility and outline metadata are preserved.

Parameters

columnWidths System.Collections.Generic.IReadOnlyDictionary<int, OfficeIMO.Excel.ExcelColumnWidth> required
Widths keyed by 1-based column index. Widths above 255 are clamped.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope DefaultColumnWidth(ExcelColumnWidth width, bool save = true) #

Sets the worksheet default column width from characters or a physical length.

Parameters

width OfficeIMO.Excel.ExcelColumnWidth required
Default column width. Excel supports resolved widths up to 255 character units.
save bool = true optional
Whether to save the worksheet XML immediately.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope DefaultRowHeight(ExcelColumnWidth height, bool hidden = false, bool save = true) #

Sets the worksheet default row height from characters or a physical length.

Parameters

height OfficeIMO.Excel.ExcelColumnWidth required
Default row height. Excel supports physical heights up to 409 points.
hidden bool = false optional
Whether empty rows should be hidden by default.
save bool = true optional
Whether to save the worksheet XML immediately.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Document(Action<ExcelDocument> configure) #

Configures ExcelSheet.Document in place: Gets the workbook that owns this worksheet.

Parameters

configure System.Action<OfficeIMO.Excel.ExcelDocument> required
Configures the value.

Returns

ExcelSheetScope The same scope.
ExecutionOverride 2 overloads
public ExcelSheetScope ExecutionOverride(ExcelExecutionPolicy? value) #

Sets ExcelSheet.ExecutionOverride: Override execution policy for this sheet. Null = inherit from document.

Parameters

value OfficeIMO.Excel.ExcelExecutionPolicy? required
The value.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope ExecutionOverride(Action<ExcelExecutionPolicy> configure) #

Configures ExcelSheet.ExecutionOverride in place (creating it when not set): Override execution policy for this sheet. Null = inherit from document.

Parameters

configure System.Action<OfficeIMO.Excel.ExcelExecutionPolicy> required
Configures the value.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Hidden(bool hidden = true) #

Hides or shows the worksheet in the workbook.

Parameters

hidden bool = true optional
The value. True when omitted.

Returns

ExcelSheetScope The same scope.
Image 6 overloads
public ExcelSheetScope Image(int row, int column, byte[] imageBytes, ExcelImageOptions? options = null, Action<ExcelImageScope>? configure = null) #

Embeds native image bytes at a one-based cell and returns the attached image.

Parameters

row int required
The value.
column int required
The value.
imageBytes byte[] required
The value.
options OfficeIMO.Excel.ExcelImageOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelImageScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Image(int row, int column, string path, ExcelImageOptions? options = null, Action<ExcelImageScope>? configure = null) #

Loads an image from a file at a one-based cell and returns the attached image.

Parameters

row int required
The value.
column int required
The value.
path string required
The value.
options OfficeIMO.Excel.ExcelImageOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelImageScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Image(int row, int column, Stream stream, ExcelImageOptions? options = null, Action<ExcelImageScope>? configure = null) #

Loads an image from a stream at a one-based cell and returns the attached image.

Parameters

row int required
The value.
column int required
The value.
stream System.IO.Stream required
The value.
options OfficeIMO.Excel.ExcelImageOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelImageScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Image(string cellOrRange, byte[] imageBytes, ExcelImageOptions? options = null, Action<ExcelImageScope>? configure = null) #

Embeds native image bytes at an A1 cell or two-cell range and returns the attached image.

Parameters

cellOrRange string required
The value.
imageBytes byte[] required
The value.
options OfficeIMO.Excel.ExcelImageOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelImageScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Image(string cellOrRange, string path, ExcelImageOptions? options = null, Action<ExcelImageScope>? configure = null) #

Loads an image from a file at an A1 cell or two-cell range and returns the attached image.

Parameters

cellOrRange string required
The value.
path string required
The value.
options OfficeIMO.Excel.ExcelImageOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelImageScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Image(string cellOrRange, Stream stream, ExcelImageOptions? options = null, Action<ExcelImageScope>? configure = null) #

Loads an image from a stream at an A1 cell or two-cell range and returns the attached image.

Parameters

cellOrRange string required
The value.
stream System.IO.Stream required
The value.
options OfficeIMO.Excel.ExcelImageOptions? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelImageScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope ModernChart(ExcelChartData data, int row, int column, ExcelModernChartType chartType, string? title = null, OfficeLength? width = null, OfficeLength? height = null, Action<ExcelModernChartScope>? configure = null) #

Adds a native ChartEx chart backed by OfficeIMO's shared hidden chart-data owner.

Parameters

data OfficeIMO.Excel.ExcelChartData required
The value.
row int required
The value.
column int required
The value.
chartType OfficeIMO.Excel.ExcelModernChartType required
The value.
title string? = null optional
The value.
width OfficeIMO.OfficeLength? = null optional
The value.
height OfficeIMO.OfficeLength? = null optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelModernChartScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Name(string value) #

Sets ExcelSheet.Name: Gets or sets the worksheet name.

Parameters

value string required
The value.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope OutlineSummary(bool? summaryBelow = null, bool? summaryRight = null) #

Configures the worksheet outline summary positions shown by Excel.

Parameters

summaryBelow bool? = null optional
Whether row summaries should appear below grouped rows.
summaryRight bool? = null optional
Whether column summaries should appear to the right of grouped columns.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope PageSetup(Action<ExcelSheetPageSetup> configure) #

Configures ExcelSheet.PageSetup in place: Paper, orientation, scaling, margins, print area and titles, print options, headers and footers.

Parameters

configure System.Action<OfficeIMO.Excel.ExcelSheetPageSetup> required
Configures the value.

Returns

ExcelSheetScope The same scope.
Range 2 overloads
public ExcelSheetScope Range(string a1Range, Action<ExcelRangeScope>? configure = null) #

Returns a range by A1 address, such as A1:V1. A single cell reference returns a one-cell range.

Parameters

a1Range string required
The value.
configure System.Action<OfficeIMO.Excel.ExcelRangeScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Range(int firstRow, int firstColumn, int lastRow, int lastColumn, Action<ExcelRangeScope>? configure = null) #

Returns the range between two 1-based corner cells.

Parameters

firstRow int required
The value.
firstColumn int required
The value.
lastRow int required
The value.
lastColumn int required
The value.
configure System.Action<OfficeIMO.Excel.ExcelRangeScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
Sparklines 2 overloads
public ExcelSheetScope Sparklines(string dataRange, string locationRange, ExcelSparklineType type, bool displayMarkers = false, bool displayHighLow = false, bool displayFirstLast = false, bool displayNegative = false, bool displayAxis = false, OfficeColor? seriesColor = null, OfficeColor? axisColor = null, OfficeColor? negativeColor = null, OfficeColor? markersColor = null, OfficeColor? highColor = null, OfficeColor? lowColor = null, OfficeColor? firstColor = null, OfficeColor? lastColor = null, Action<ExcelSparklineGroupScope>? configure = null) #

Adds sparklines to the worksheet.

Parameters

dataRange string required
A1 range containing the data (e.g., "B2:M2").
locationRange string required
A1 range where sparklines will be placed (e.g., "N2:N2").
type OfficeIMO.Excel.ExcelSparklineType required
Sparkline type.
displayMarkers bool = false optional
Show markers for each data point.
displayHighLow bool = false optional
Show high/low markers.
displayFirstLast bool = false optional
Show first/last markers.
displayNegative bool = false optional
Show negative markers.
displayAxis bool = false optional
Show axis.
seriesColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
axisColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
negativeColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
markersColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
highColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
lowColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
firstColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
lastColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
configure System.Action<OfficeIMO.Excel.ExcelSparklineGroupScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Sparklines(string dataRange, string locationRange, bool displayMarkers = false, bool displayHighLow = false, bool displayFirstLast = false, bool displayNegative = false, bool displayAxis = false, OfficeColor? seriesColor = null, OfficeColor? axisColor = null, OfficeColor? negativeColor = null, OfficeColor? markersColor = null, OfficeColor? highColor = null, OfficeColor? lowColor = null, OfficeColor? firstColor = null, OfficeColor? lastColor = null, Action<ExcelSparklineGroupScope>? configure = null) #

Adds line sparklines to the worksheet.

Parameters

dataRange string required
A1 range containing the data (e.g., "B2:M2").
locationRange string required
A1 range where sparklines will be placed (e.g., "N2:N2").
displayMarkers bool = false optional
Show markers for each data point.
displayHighLow bool = false optional
Show high/low markers.
displayFirstLast bool = false optional
Show first/last markers.
displayNegative bool = false optional
Show negative markers.
displayAxis bool = false optional
Show axis.
seriesColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
axisColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
negativeColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
markersColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
highColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
lowColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
firstColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
lastColor OfficeIMO.OfficeColor? = null optional
Optional literal color or theme role.
configure System.Action<OfficeIMO.Excel.ExcelSparklineGroupScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope TabColor(OfficeColor color) #

Sets a literal or theme-based worksheet tab color.

Parameters

color OfficeIMO.OfficeColor required
A literal RGBA color, native theme role or status color.

Returns

ExcelSheetScope The same scope.
Table 2 overloads
public ExcelSheetScope Table(string range, bool hasHeader = true, string? name = null, ExcelTableStyle style = TableStyleMedium2, bool includeAutoFilter = true, ExcelTableNameValidationMode validationMode = Sanitize, Action<ExcelTableScope>? configure = null) #

Adds an Excel table to the worksheet over the specified range with optional AutoFilter and name validation behavior.

Parameters

range string required
Cell range (e.g. "A1:B3") defining the table area.
hasHeader bool = true optional
Indicates whether the first row is a header row.
name string? = null optional
Name of the table. If empty, a default name is used. Examples: "My Table" becomes "My_Table"; "123Report" becomes "_123Report"; spaces and invalid characters are replaced with underscores. If a name already exists in this workbook, a numeric suffix is appended (e.g., "Table", "Table2").
style OfficeIMO.Excel.ExcelTableStyle = TableStyleMedium2 optional
Table style to apply.
includeAutoFilter bool = true optional
Whether to include AutoFilter dropdowns in the table headers.
validationMode OfficeIMO.Excel.ExcelTableNameValidationMode = Sanitize optional
Controls how invalid table names are handled: ExcelTableNameValidationMode.Sanitize (default) replaces invalid characters and adjusts the name; ExcelTableNameValidationMode.Strict throws descriptive exceptions for invalid names.
configure System.Action<OfficeIMO.Excel.ExcelTableScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Table(DataTable data, OfficeTableOptions? options = null, int row = 1, int column = 1, Action<ExcelTableScope>? configure = null) #

Adds an editable native table from a data table, preserving its typed cell values.

Parameters

data System.Data.DataTable required
The value.
options OfficeIMO.OfficeTableOptions? = null optional
The value.
row int = 1 optional
The value.
column int = 1 optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelTableScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope TableStyle(string tableOrRange, ExcelTableStyle style, bool? showFirstColumn = null, bool? showLastColumn = null, bool? showRowStripes = null, bool? showColumnStripes = null) #

Updates the visual style flags for the table identified by range, name, or display name.

Parameters

tableOrRange string required
Table range, name, or display name.
style OfficeIMO.Excel.ExcelTableStyle required
Table style to apply.
showFirstColumn bool? = null optional
Optional first-column emphasis flag.
showLastColumn bool? = null optional
Optional last-column emphasis flag.
showRowStripes bool? = null optional
Optional row stripe flag.
showColumnStripes bool? = null optional
Optional column stripe flag.

Returns

ExcelSheetScope The same scope.
Table``1 2 overloads
public ExcelSheetScope Table<T>(IEnumerable<T?> rows, OfficeTableOptions? options = null, int row = 1, int column = 1, Action<ExcelTableScope>? configure = null) #

Adds an editable native table from typed rows, with columns from the public properties and fields of T.

Type Parameters

T
Row type.

Parameters

rows System.Collections.Generic.IEnumerable<T?> required
Rows to write.
options OfficeIMO.OfficeTableOptions? = null optional
Column selection, ordering, header, formatting, name and style options.
row int = 1 optional
One-based row of the table's top-left cell.
column int = 1 optional
One-based column of the table's top-left cell.
configure System.Action<OfficeIMO.Excel.ExcelTableScope>? = null optional
Edits the created table.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope Table<T>(IEnumerable<T?> rows, ValueTuple<string, Func<T?, object?>>[] columns, OfficeTableOptions? options = null, int row = 1, int column = 1, Action<ExcelTableScope>? configure = null) #

Adds an attached native table using explicit AOT-safe column selectors and the ordinary table options.

Type Parameters

T
The type of the value.

Parameters

rows System.Collections.Generic.IEnumerable<T?> required
The value.
columns System.ValueTuple<string, System.Func<T?, object?>>[] required
The value.
options OfficeIMO.OfficeTableOptions? = null optional
The value.
row int = 1 optional
The value.
column int = 1 optional
The value.
configure System.Action<OfficeIMO.Excel.ExcelTableScope>? = null optional
Configures the new item through its scope.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope VeryHidden(bool veryHidden = true) #

Makes the worksheet very hidden, or restores it to visible.

Parameters

veryHidden bool = true optional
Whether to set the worksheet to the very hidden workbook state. True when omitted.

Returns

ExcelSheetScope The same scope.
public ExcelSheetScope View(Action<ExcelSheetView> configure) #

Configures ExcelSheet.View in place: Frozen panes, gridlines, zero values, headings, direction, zoom and view mode.

Parameters

configure System.Action<OfficeIMO.Excel.ExcelSheetView> required
Configures the value.

Returns

ExcelSheetScope The same scope.

Properties

public ExcelSheet Model { get; } #

The ExcelSheet this scope edits, for plain C# inside a lambda.