OfficeIMO

API Reference

Class

ExcelSheet

Namespace OfficeIMO.Excel
Assembly OfficeIMO.Excel
Implements
IDisposable

Helpers for worksheet cell comments (notes).

Inheritance

  • Object
  • ExcelSheet

Constructors

ExcelSheet 2 overloads
public ExcelSheet(ExcelDocument excelDocument, SpreadsheetDocument spreadSheetDocument, Sheet sheet) #

Initializes a worksheet from an existing Sheet element.

Parameters

excelDocument OfficeIMO.Excel.ExcelDocument requiredposition: 0
Parent document.
spreadSheetDocument DocumentFormat.OpenXml.Packaging.SpreadsheetDocument requiredposition: 1
Open XML spreadsheet document.
sheet DocumentFormat.OpenXml.Spreadsheet.Sheet requiredposition: 2
Underlying sheet element.
public ExcelSheet(ExcelDocument excelDocument, WorkbookPart workbookpart, SpreadsheetDocument spreadSheetDocument, String name) #

Creates a new worksheet and appends it to the workbook.

Parameters

excelDocument OfficeIMO.Excel.ExcelDocument requiredposition: 0
Parent document.
workbookpart DocumentFormat.OpenXml.Packaging.WorkbookPart requiredposition: 1
Workbook part to add the worksheet to.
spreadSheetDocument DocumentFormat.OpenXml.Packaging.SpreadsheetDocument requiredposition: 2
Open XML spreadsheet document.
name System.String requiredposition: 3
Worksheet name.

Methods

public Void AddAutoFilter(String range, Dictionary<UInt32, IEnumerable<String>> filterCriteria = null) #
Returns: Void

Adds an AutoFilter to the worksheet or table.

Parameters

range System.String requiredposition: 0
The cell range to apply the filter to.
filterCriteria System.Collections.Generic.Dictionary{System.UInt32,System.Collections.Generic.IEnumerable{System.String}} = null optionalposition: 1
Optional filter criteria to apply.
public ExcelChart AddBubbleChartFromRanges(IEnumerable<ExcelChartSeriesRange> seriesRanges, Int32 row, Int32 column, Int32 widthPixels = 640, Int32 heightPixels = 360, String title = null) #
Returns: ExcelChart

Adds a bubble chart using explicit X/Y/size ranges.

Parameters

seriesRanges System.Collections.Generic.IEnumerable{OfficeIMO.Excel.ExcelChartSeriesRange} requiredposition: 0
row System.Int32 requiredposition: 1
column System.Int32 requiredposition: 2
widthPixels System.Int32 = 640 optionalposition: 3
heightPixels System.Int32 = 360 optionalposition: 4
title System.String = null optionalposition: 5
AddChart 2 overloads
public ExcelChart AddChart(ExcelChartData data, Int32 row, Int32 column, Int32 widthPixels = 640, Int32 heightPixels = 360, ExcelChartType type = ColumnClustered, String title = null) #
Returns: ExcelChart

Adds a chart to the worksheet using the provided data. Data is stored on a hidden chart data sheet.

Parameters

data OfficeIMO.Excel.ExcelChartData requiredposition: 0
row System.Int32 requiredposition: 1
column System.Int32 requiredposition: 2
widthPixels System.Int32 = 640 optionalposition: 3
heightPixels System.Int32 = 360 optionalposition: 4
type OfficeIMO.Excel.ExcelChartType = ColumnClustered optionalposition: 5
title System.String = null optionalposition: 6
public ExcelChart AddChart(ExcelChartDataRange dataRange, Int32 row, Int32 column, Int32 widthPixels = 640, Int32 heightPixels = 360, ExcelChartType type = ColumnClustered, ExcelChartData cachedData = null, String title = null) #
Returns: ExcelChart

Adds a chart to the worksheet using an existing data range.

Parameters

dataRange OfficeIMO.Excel.ExcelChartDataRange requiredposition: 0
row System.Int32 requiredposition: 1
column System.Int32 requiredposition: 2
widthPixels System.Int32 = 640 optionalposition: 3
heightPixels System.Int32 = 360 optionalposition: 4
type OfficeIMO.Excel.ExcelChartType = ColumnClustered optionalposition: 5
cachedData OfficeIMO.Excel.ExcelChartData = null optionalposition: 6
title System.String = null optionalposition: 7
public ExcelChart AddChartFromRange(String dataRangeA1, Int32 row, Int32 column, Int32 widthPixels = 640, Int32 heightPixels = 360, ExcelChartType type = ColumnClustered, Boolean hasHeaders = true, String title = null, Boolean includeCachedData = true) #
Returns: ExcelChart

Adds a chart using an A1 range on this sheet.

Parameters

dataRangeA1 System.String requiredposition: 0
row System.Int32 requiredposition: 1
column System.Int32 requiredposition: 2
widthPixels System.Int32 = 640 optionalposition: 3
heightPixels System.Int32 = 360 optionalposition: 4
type OfficeIMO.Excel.ExcelChartType = ColumnClustered optionalposition: 5
hasHeaders System.Boolean = true optionalposition: 6
title System.String = null optionalposition: 7
includeCachedData System.Boolean = true optionalposition: 8
public ExcelChart AddChartFromTable(String tableName, Int32 row, Int32 column, Int32 widthPixels = 640, Int32 heightPixels = 360, ExcelChartType type = ColumnClustered, String title = null, Boolean includeCachedData = true) #
Returns: ExcelChart

Adds a chart from a table name on this sheet.

Parameters

tableName System.String requiredposition: 0
row System.Int32 requiredposition: 1
column System.Int32 requiredposition: 2
widthPixels System.Int32 = 640 optionalposition: 3
heightPixels System.Int32 = 360 optionalposition: 4
type OfficeIMO.Excel.ExcelChartType = ColumnClustered optionalposition: 5
title System.String = null optionalposition: 6
includeCachedData System.Boolean = true optionalposition: 7
AddConditionalColorScale 2 overloads
public Void AddConditionalColorScale(String range, Color startColor, Color endColor) #
Returns: Void

Adds a two-color scale conditional format to a range.

Parameters

range System.String requiredposition: 0
A1-style range to format.
startColor SixLabors.ImageSharp.Color requiredposition: 1
Starting color of the scale.
endColor SixLabors.ImageSharp.Color requiredposition: 2
Ending color of the scale.
public Void AddConditionalColorScale(String range, String startColor, String endColor) #
Returns: Void

Adds a two-color scale conditional format to a range using hex colors.

Parameters

range System.String requiredposition: 0
A1-style range to format.
startColor System.String requiredposition: 1
Starting color in hex (e.g. FF0000).
endColor System.String requiredposition: 2
Ending color in hex.
AddConditionalDataBar 2 overloads
public Void AddConditionalDataBar(String range, Color color) #
Returns: Void

Adds a data bar conditional format to a range.

Parameters

range System.String requiredposition: 0
A1-style range to format.
color SixLabors.ImageSharp.Color requiredposition: 1
Bar color.
public Void AddConditionalDataBar(String range, String color) #
Returns: Void

Adds a data bar conditional format to a range using a hex color.

Parameters

range System.String requiredposition: 0
A1-style range to format.
color System.String requiredposition: 1
Bar color in hex (e.g. FF0000).
AddConditionalIconSet 3 overloads
public Void AddConditionalIconSet(String range, IconSetValues iconSet, Boolean showValue, Boolean reverseIconOrder) #
Returns: Void

Adds an icon set conditional format to a range.

Parameters

range System.String requiredposition: 0
A1-style range to format.
iconSet DocumentFormat.OpenXml.Spreadsheet.IconSetValues requiredposition: 1
Icon set type (e.g., ThreeTrafficLights1, ThreeSymbols, FourArrows, FiveRatings).
showValue System.Boolean requiredposition: 2
Whether to display the underlying cell values.
reverseIconOrder System.Boolean requiredposition: 3
Reverse icon order.
public Void AddConditionalIconSet(String range, IconSetValues iconSet, Boolean showValue, Boolean reverseIconOrder, Double[] percentThresholds, Double[] numberThresholds) #
Returns: Void

Adds an icon set conditional format to a range with optional explicit thresholds. Provide either percentThresholds (0..100) or numberThresholds as absolute values. The number of thresholds must match the icon count for the selected icon set (3/4/5).

Parameters

range System.String requiredposition: 0
iconSet DocumentFormat.OpenXml.Spreadsheet.IconSetValues requiredposition: 1
showValue System.Boolean requiredposition: 2
reverseIconOrder System.Boolean requiredposition: 3
percentThresholds System.Double[] requiredposition: 4
numberThresholds System.Double[] requiredposition: 5
public Void AddConditionalIconSet(String range) #
Returns: Void

Overload with common defaults for convenience.

Parameters

range System.String requiredposition: 0
public Void AddConditionalRule(String range, ConditionalFormattingOperatorValues operator, String formula1, String formula2 = null) #
Returns: Void

Adds a conditional formatting rule to the specified range.

Parameters

range System.String requiredposition: 0
A1-style range to apply the rule to.
operator DocumentFormat.OpenXml.Spreadsheet.ConditionalFormattingOperatorValues requiredposition: 1
Comparison operator for the rule.
formula1 System.String requiredposition: 2
Primary formula or value.
formula2 System.String = null optionalposition: 3
Optional secondary formula or value.
public Void AddImageAt(Int32 row, Int32 column, Byte[] imageBytes, String contentType = "image/png", Int32 widthPixels = 96, Int32 heightPixels = 32, Int32 offsetXPixels = 0, Int32 offsetYPixels = 0) #
Returns: Void

Adds an image anchored to the specified cell. The top-left of the image will align to the cell's top-left, with optional pixel offsets. Size is specified in pixels and converted to EMUs.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
imageBytes System.Byte[] requiredposition: 2
Image bytes.
contentType System.String = "image/png" optionalposition: 3
Content type, e.g. image/png or image/jpeg.
widthPixels System.Int32 = 96 optionalposition: 4
Width in pixels.
heightPixels System.Int32 = 32 optionalposition: 5
Height in pixels.
offsetXPixels System.Int32 = 0 optionalposition: 6
Optional X offset from cell origin in pixels.
offsetYPixels System.Int32 = 0 optionalposition: 7
Optional Y offset from cell origin in pixels.
public Void AddImageFromUrlAt(Int32 row, Int32 column, String url, Int32 widthPixels = 96, Int32 heightPixels = 32, Int32 offsetXPixels = 0, Int32 offsetYPixels = 0) #
Returns: Void

Downloads an image from URL (with timeout and size limits) and anchors it to the specified cell.

Parameters

row System.Int32 requiredposition: 0
1-based row index where the top edge of the image will be anchored.
column System.Int32 requiredposition: 1
1-based column index where the left edge of the image will be anchored.
url System.String requiredposition: 2
Remote image URL to download. Requests timeout after 5 seconds and must be smaller than 2 MB.
widthPixels System.Int32 = 96 optionalposition: 3
Desired image width in pixels. Defaults to 96 px, converted to English Metric Units (EMUs) for OpenXML positioning.
heightPixels System.Int32 = 32 optionalposition: 4
Desired image height in pixels. Defaults to 32 px, converted to EMUs.
offsetXPixels System.Int32 = 0 optionalposition: 5
Optional horizontal offset in pixels from the cell's left boundary. Positive values move the image right; defaults to 0 px.
offsetYPixels System.Int32 = 0 optionalposition: 6
Optional vertical offset in pixels from the cell's top boundary. Positive values move the image down; defaults to 0 px.
public Void AddPivotTable(String sourceRange, String destinationCell, String name = null, IEnumerable<String> rowFields = null, IEnumerable<String> columnFields = null, IEnumerable<String> pageFields = null, IEnumerable<ExcelPivotDataField> dataFields = null, Boolean showRowGrandTotals = true, Boolean showColumnGrandTotals = true, String pivotStyleName = null, ExcelPivotLayout layout = Compact, Nullable<Boolean> dataOnRows = null, Nullable<Boolean> showHeaders = null, Nullable<Boolean> showEmptyRows = null, Nullable<Boolean> showEmptyColumns = null, Nullable<Boolean> showDrill = null) #
Returns: Void

Adds a basic pivot table based on a source range and places it at a destination cell.

Parameters

sourceRange System.String requiredposition: 0
Source data range (including header row), e.g. "A1:D100".
destinationCell System.String requiredposition: 1
Top-left cell for the pivot table (e.g. "F2").
name System.String = null optionalposition: 2
Optional pivot table name. Defaults to "PivotTable1" style.
rowFields System.Collections.Generic.IEnumerable{System.String} = null optionalposition: 3
Optional row fields (header names).
columnFields System.Collections.Generic.IEnumerable{System.String} = null optionalposition: 4
Optional column fields (header names).
pageFields System.Collections.Generic.IEnumerable{System.String} = null optionalposition: 5
Optional page fields (header names) used as filters.
dataFields System.Collections.Generic.IEnumerable{OfficeIMO.Excel.ExcelPivotDataField} = null optionalposition: 6
Optional data field definitions. Defaults to last column with Sum.
showRowGrandTotals System.Boolean = true optionalposition: 7
Show row grand totals.
showColumnGrandTotals System.Boolean = true optionalposition: 8
Show column grand totals.
pivotStyleName System.String = null optionalposition: 9
Optional pivot table style name.
layout OfficeIMO.Excel.ExcelPivotLayout = Compact optionalposition: 10
Layout mode (Compact, Outline, Tabular).
dataOnRows System.Nullable{System.Boolean} = null optionalposition: 11
Whether to show data fields on rows instead of columns.
showHeaders System.Nullable{System.Boolean} = null optionalposition: 12
Whether to show field headers.
showEmptyRows System.Nullable{System.Boolean} = null optionalposition: 13
Whether to show empty rows.
showEmptyColumns System.Nullable{System.Boolean} = null optionalposition: 14
Whether to show empty columns.
showDrill System.Nullable{System.Boolean} = null optionalposition: 15
Whether to show drill indicators.
public ExcelChart AddScatterChartFromRanges(IEnumerable<ExcelChartSeriesRange> seriesRanges, Int32 row, Int32 column, Int32 widthPixels = 640, Int32 heightPixels = 360, String title = null) #
Returns: ExcelChart

Adds a scatter chart using explicit X/Y ranges.

Parameters

seriesRanges System.Collections.Generic.IEnumerable{OfficeIMO.Excel.ExcelChartSeriesRange} requiredposition: 0
row System.Int32 requiredposition: 1
column System.Int32 requiredposition: 2
widthPixels System.Int32 = 640 optionalposition: 3
heightPixels System.Int32 = 360 optionalposition: 4
title System.String = null optionalposition: 5
AddSparklines 2 overloads
public Void AddSparklines(String dataRange, String locationRange, SparklineTypeValues type, Boolean displayMarkers = false, Boolean displayHighLow = false, Boolean displayFirstLast = false, Boolean displayNegative = false, Boolean displayAxis = false, String seriesColor = null, String axisColor = null, String negativeColor = null, String markersColor = null, String highColor = null, String lowColor = null, String firstColor = null, String lastColor = null) #
Returns: Void

Adds sparklines to the worksheet.

Parameters

dataRange System.String requiredposition: 0
A1 range containing the data (e.g., "B2:M2").
locationRange System.String requiredposition: 1
A1 range where sparklines will be placed (e.g., "N2:N2").
type DocumentFormat.OpenXml.Office2010.Excel.SparklineTypeValues requiredposition: 2
Sparkline type.
displayMarkers System.Boolean = false optionalposition: 3
Show markers for each data point.
displayHighLow System.Boolean = false optionalposition: 4
Show high/low markers.
displayFirstLast System.Boolean = false optionalposition: 5
Show first/last markers.
displayNegative System.Boolean = false optionalposition: 6
Show negative markers.
displayAxis System.Boolean = false optionalposition: 7
Show axis.
seriesColor System.String = null optionalposition: 8
Sparkline series color (#RRGGBB or #AARRGGBB).
axisColor System.String = null optionalposition: 9
Axis color (#RRGGBB or #AARRGGBB).
negativeColor System.String = null optionalposition: 10
Negative point color (#RRGGBB or #AARRGGBB).
markersColor System.String = null optionalposition: 11
Markers color (#RRGGBB or #AARRGGBB).
highColor System.String = null optionalposition: 12
High point color (#RRGGBB or #AARRGGBB).
lowColor System.String = null optionalposition: 13
Low point color (#RRGGBB or #AARRGGBB).
firstColor System.String = null optionalposition: 14
First point color (#RRGGBB or #AARRGGBB).
lastColor System.String = null optionalposition: 15
Last point color (#RRGGBB or #AARRGGBB).
public Void AddSparklines(String dataRange, String locationRange, Boolean displayMarkers = false, Boolean displayHighLow = false, Boolean displayFirstLast = false, Boolean displayNegative = false, Boolean displayAxis = false, String seriesColor = null, String axisColor = null, String negativeColor = null, String markersColor = null, String highColor = null, String lowColor = null, String firstColor = null, String lastColor = null) #
Returns: Void

Adds line sparklines to the worksheet.

Parameters

dataRange System.String requiredposition: 0
A1 range containing the data (e.g., "B2:M2").
locationRange System.String requiredposition: 1
A1 range where sparklines will be placed (e.g., "N2:N2").
displayMarkers System.Boolean = false optionalposition: 2
Show markers for each data point.
displayHighLow System.Boolean = false optionalposition: 3
Show high/low markers.
displayFirstLast System.Boolean = false optionalposition: 4
Show first/last markers.
displayNegative System.Boolean = false optionalposition: 5
Show negative markers.
displayAxis System.Boolean = false optionalposition: 6
Show axis.
seriesColor System.String = null optionalposition: 7
Sparkline series color (#RRGGBB or #AARRGGBB).
axisColor System.String = null optionalposition: 8
Axis color (#RRGGBB or #AARRGGBB).
negativeColor System.String = null optionalposition: 9
Negative point color (#RRGGBB or #AARRGGBB).
markersColor System.String = null optionalposition: 10
Markers color (#RRGGBB or #AARRGGBB).
highColor System.String = null optionalposition: 11
High point color (#RRGGBB or #AARRGGBB).
lowColor System.String = null optionalposition: 12
Low point color (#RRGGBB or #AARRGGBB).
firstColor System.String = null optionalposition: 13
First point color (#RRGGBB or #AARRGGBB).
lastColor System.String = null optionalposition: 14
Last point color (#RRGGBB or #AARRGGBB).
AddTable 2 overloads
public Void AddTable(String range, Boolean hasHeader, String name, TableStyle style) #
Returns: Void

Adds an Excel table to the worksheet over the specified range.

Parameters

range System.String requiredposition: 0
Cell range (e.g. "A1:B3") defining the table area.
hasHeader System.Boolean requiredposition: 1
Indicates whether the first row is a header row.
name System.String requiredposition: 2
Name of the table. If empty, a default name is used.
style OfficeIMO.Excel.TableStyle requiredposition: 3
Table style to apply.

Exceptions

  • ArgumentNullException – Thrown when range is null or empty.
  • ArgumentException – Thrown when range is not in a valid format.
  • InvalidOperationException – Thrown when the specified range overlaps with an existing table.
public Void AddTable(String range, Boolean hasHeader, String name, TableStyle style, Boolean includeAutoFilter, TableNameValidationMode validationMode = Sanitize) #
Returns: Void

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

Parameters

range System.String requiredposition: 0
Cell range (e.g. "A1:B3") defining the table area.
hasHeader System.Boolean requiredposition: 1
Indicates whether the first row is a header row.
name System.String requiredposition: 2
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.TableStyle requiredposition: 3
Table style to apply.
includeAutoFilter System.Boolean requiredposition: 4
Whether to include AutoFilter dropdowns in the table headers.
validationMode OfficeIMO.Excel.TableNameValidationMode = Sanitize optionalposition: 5
Controls how invalid table names are handled: Sanitize (default) replaces invalid characters and adjusts the name; Strict throws descriptive exceptions for invalid names.
public Void AutoFilterAdd(String a1Range) #
Returns: Void

Attaches an AutoFilter to the given A1 range (e.g., "A1:C200").

Parameters

a1Range System.String requiredposition: 0
public Void AutoFilterByHeaderBetween(String header, Double minimumInclusive, Double maximumInclusive) #
Returns: Void

Applies an AutoFilter numeric inclusive range filter to a column resolved by header within the current AutoFilter range.

Parameters

header System.String requiredposition: 0
minimumInclusive System.Double requiredposition: 1
maximumInclusive System.Double requiredposition: 2
public Void AutoFilterByHeaderContains(String header, String containsText) #
Returns: Void

Applies an AutoFilter text contains filter to a column resolved by header within the current AutoFilter range. Uses wildcard pattern matching ("*text*") via CustomFilters with Equal operator. When the header is missing the operation is skipped.

Parameters

header System.String requiredposition: 0
containsText System.String requiredposition: 1
public Void AutoFilterByHeaderDoesNotContain(String header, String containsText) #
Returns: Void

Applies an AutoFilter text does-not-contain filter to a column resolved by header within the current AutoFilter range. Uses wildcard pattern matching ("*text*") via CustomFilters with NotEqual operator.

Parameters

header System.String requiredposition: 0
containsText System.String requiredposition: 1
public Void AutoFilterByHeaderEndsWith(String header, String endsWithText) #
Returns: Void

Applies an AutoFilter text ends-with filter to a column resolved by header within the current AutoFilter range. Uses wildcard pattern matching ("*text") via CustomFilters with Equal operator.

Parameters

header System.String requiredposition: 0
endsWithText System.String requiredposition: 1
public Void AutoFilterByHeaderEquals(String header, IEnumerable<String> values) #
Returns: Void

Applies an AutoFilter equals filter to a column resolved by header within the current AutoFilter range. Ensures an AutoFilter exists over the sheet's UsedRange when none is present. When the header is missing the operation is skipped.

Parameters

header System.String requiredposition: 0
values System.Collections.Generic.IEnumerable{System.String} requiredposition: 1
public Void AutoFilterByHeaderGreaterThanOrEqual(String header, Double value) #
Returns: Void

Applies an AutoFilter numeric greater-than-or-equal filter to a column resolved by header within the current AutoFilter range.

Parameters

header System.String requiredposition: 0
value System.Double requiredposition: 1
public Void AutoFilterByHeaderLessThanOrEqual(String header, Double value) #
Returns: Void

Applies an AutoFilter numeric less-than-or-equal filter to a column resolved by header within the current AutoFilter range.

Parameters

header System.String requiredposition: 0
value System.Double requiredposition: 1
public Void AutoFilterByHeaderNotBetween(String header, Double minimumExclusive, Double maximumExclusive) #
Returns: Void

Applies an AutoFilter numeric outside-range filter to a column resolved by header within the current AutoFilter range. Values lower than minimumExclusive or higher than maximumExclusive remain visible.

Parameters

header System.String requiredposition: 0
minimumExclusive System.Double requiredposition: 1
maximumExclusive System.Double requiredposition: 2
public Void AutoFilterByHeaderNotEqual(String header, Double value) #
Returns: Void

Applies an AutoFilter numeric not-equal filter to a column resolved by header within the current AutoFilter range.

Parameters

header System.String requiredposition: 0
value System.Double requiredposition: 1
public Void AutoFilterByHeadersEquals(params ValueTuple<String, IEnumerable<String>>[] filters) #
Returns: Void

Applies equals filters for multiple headers at once (AND semantics across columns, OR semantics within a column). Headers that cannot be resolved are ignored.

Parameters

filters System.ValueTuple{System.String,System.Collections.Generic.IEnumerable{System.String}}[] requiredposition: 0
public Void AutoFilterByHeaderStartsWith(String header, String startsWithText) #
Returns: Void

Applies an AutoFilter text starts-with filter to a column resolved by header within the current AutoFilter range. Uses wildcard pattern matching ("text*") via CustomFilters with Equal operator.

Parameters

header System.String requiredposition: 0
startsWithText System.String requiredposition: 1
public Void AutoFilterClear() #
Returns: Void

Clears any AutoFilter from the worksheet.

public Void AutoFitColumn(Int32 columnIndex) #
Returns: Void

Auto-fits the width of the specified column based on its contents.

Parameters

columnIndex System.Int32 requiredposition: 0
1-based column index.
public Void AutoFitColumns(Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void

Automatically fits all columns based on their content.

Parameters

mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 0
Overrides how the auto-fit work is scheduled across columns.
ct System.Threading.CancellationToken = null optionalposition: 1
Cancels the auto-fit pass while widths are being measured or applied.
public Void AutoFitColumnsExcept(IEnumerable<Int32> columnsToSkip, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void

Automatically fits all columns except the supplied indexes.

Parameters

columnsToSkip System.Collections.Generic.IEnumerable{System.Int32} requiredposition: 0
1-based column indexes that should not be resized.
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 1
Overrides how the auto-fit work is scheduled for the remaining columns.
ct System.Threading.CancellationToken = null optionalposition: 2
Cancels the auto-fit pass before it completes.
public Void AutoFitColumnsFor(IEnumerable<Int32> columnIndexes, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void

Automatically fits the supplied set of column indexes.

Parameters

columnIndexes System.Collections.Generic.IEnumerable{System.Int32} requiredposition: 0
1-based column indexes that should be resized to fit their content.
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 1
Overrides how the auto-fit work is scheduled across the selected columns.
ct System.Threading.CancellationToken = null optionalposition: 2
Cancels the auto-fit pass for the selected columns.
public Void AutoFitRow(Int32 rowIndex) #
Returns: Void

Auto-fits the height of the specified row based on its contents.

Parameters

rowIndex System.Int32 requiredposition: 0
1-based row index.
public Void AutoFitRows(Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void

Automatically fits all rows based on their content.

Parameters

mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 0
Overrides how the auto-fit work is scheduled across rows.
ct System.Threading.CancellationToken = null optionalposition: 1
Cancels the row auto-fit pass while heights are being calculated or applied.
public NoLockContext BeginNoLock() #
Returns: NoLockContext

Begin a no-lock context where operations bypass locking.

public Void Cell(Int32 row, Int32 column, Object value = null, String formula = null, String numberFormat = null) #
Returns: Void

Sets the value, formula, and number format of a cell in a single operation.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.Object = null optionalposition: 2
Optional value to assign.
formula System.String = null optionalposition: 3
Optional formula to apply.
numberFormat System.String = null optionalposition: 4
Optional number format code.
public Void CellAlign(Int32 row, Int32 column, HorizontalAlignmentValues alignment) #
Returns: Void

Applies a horizontal alignment to a single cell.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index of the cell to align.
column System.Int32 requiredposition: 1
The 1-based column index of the cell to align.
alignment DocumentFormat.OpenXml.Spreadsheet.HorizontalAlignmentValues requiredposition: 2
The horizontal alignment value to apply.
CellBackground 2 overloads
public Void CellBackground(Int32 row, Int32 column, Color color) #
Returns: Void

Applies solid background to a single cell. Accepts #RRGGBB or #AARRGGBB.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index of the cell to fill.
column System.Int32 requiredposition: 1
The 1-based column index of the cell to fill.
hexColor System.String requiredposition: 2
The background color expressed as an ARGB or RGB hex string.
CellBackground(System.Int32 row, System.Int32 column, SixLabors.ImageSharp.Color color) #

Applies solid background to a single cell using SixLabors color.

Parameters

row System.Int32 required
The 1-based row index of the cell to fill.
column System.Int32 required
The 1-based column index of the cell to fill.
color SixLabors.ImageSharp.Color required
The Color to convert to a hex value.
public Void CellBold(Int32 row, Int32 column, Boolean bold = true) #
Returns: Void

Applies bold font to a single cell.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index of the cell to modify.
column System.Int32 requiredposition: 1
The 1-based column index of the cell to modify.
bold System.Boolean = true optionalposition: 2
Whether the font should be bold (true) or regular (false).
public Void CellFontColor(Int32 row, Int32 column, String hexColor) #
Returns: Void

Applies a font color (ARGB hex or #RRGGBB) to a single cell.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index of the cell to recolor.
column System.Int32 requiredposition: 1
The 1-based column index of the cell to recolor.
hexColor System.String requiredposition: 2
The desired font color expressed as an ARGB or RGB hex string.
public Void CellFormula(Int32 row, Int32 column, String formula) #
Returns: Void

Sets a formula in the specified cell.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
formula System.String requiredposition: 2
The formula expression.
CellValue 13 overloads
public Void CellValue<T>(Int32 row, Int32 column, Nullable<T> value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Type Parameters

T

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.String requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, Double value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.Double requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, Decimal value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.Decimal requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, DateTime value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.DateTime requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, DateTimeOffset value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.DateTimeOffset requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, TimeSpan value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.TimeSpan requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, UInt32 value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.UInt32 requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, UInt64 value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.UInt64 requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, UInt16 value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.UInt16 requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, Byte value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.Byte requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, SByte value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.SByte requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, Boolean value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.Boolean requiredposition: 2
The value to assign.
public Void CellValue(Int32 row, Int32 column, Object value) #
Returns: Void

Sets the specified value into a cell, inferring the data type.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
value System.Object requiredposition: 2
The value to assign.
public Void CellValues(IEnumerable<ValueTuple<Int32, Int32, Object>> cells, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void

Writes multiple cell values efficiently, using parallelization when beneficial.

Parameters

cells System.Collections.Generic.IEnumerable{System.ValueTuple{System.Int32,System.Int32,System.Object}} requiredposition: 0
Collection of cell coordinates and values.
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 1
Optional execution mode override.
ct System.Threading.CancellationToken = null optionalposition: 2
Cancellation token.
public Void CellValuesParallel(IEnumerable<ValueTuple<Int32, Int32, Object>> cells) #
Returns: Void
Obsolete("Use CellValues(..., ExecutionMode.Parallel) instead.")

Obsolete. Use CancellationToken) with Parallel instead.

Parameters

cells System.Collections.Generic.IEnumerable{System.ValueTuple{System.Int32,System.Int32,System.Object}} requiredposition: 0
Collection of cell coordinates and values.
CellValue``1(System.Int32 row, System.Int32 column, System.Nullable{``0} value) #

Sets the value of a cell using a nullable struct.

Type Parameters

T
The value type.

Parameters

row System.Int32 required
The 1-based row index.
column System.Int32 required
The 1-based column index.
value System.Nullable{``0} required
The nullable value to assign.
ClearComment 2 overloads
public Void ClearComment(Int32 row, Int32 column) #
Returns: Void

Removes a comment from the specified cell (if present).

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
public Void ClearComment(String a1) #
Returns: Void

Removes a comment from the specified A1 cell reference (if present).

Parameters

a1 System.String requiredposition: 0
A1 cell reference (e.g., "B5").
public Void ClearHeaderCache() #
Returns: Void

Clears the cached header map.

CoerceForCellNoDom(System.Object arg1, OfficeIMO.Excel.SharedStringPlanner arg2) #

Compute-only coercion for parallel scenarios. Does not mutate DOM. Uses SharedStringPlanner for string values.

Parameters

arg1 System.Object required
arg2 OfficeIMO.Excel.SharedStringPlanner required
public ColumnStyleByHeaderBuilder ColumnStyleByHeader(String header, Boolean includeHeader = false, ExcelReadOptions options = null) #
Returns: ColumnStyleByHeaderBuilder

Returns a builder for styling a column resolved by header with discoverable methods. When the header cannot be resolved an inert builder is returned so calls become no-ops.

Parameters

header System.String requiredposition: 0
Header text used to resolve the target column after applying any configured normalization.
includeHeader System.Boolean = false optionalposition: 1
True to include the header row when styling; false to begin styling from the first data row.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 2
Read options that control header normalization and other resolution behavior.
Commit() #

Persists pending changes on this worksheet to its underlying OpenXml part.

public virtual Void Dispose() #
Returns: Void

Releases resources held by this worksheet.

EnsureDefaultStylePrimitives(DocumentFormat.OpenXml.Spreadsheet.Stylesheet arg1) #

Ensures required default style primitives exist and their counts are consistent. Excel expects at least 1 Font, 2 Fills (None, Gray125), 1 Border, 1 CellStyleFormat, and 1 CellFormat present.

Parameters

arg1 DocumentFormat.OpenXml.Spreadsheet.Stylesheet required
EnsureValidUniqueTableName(System.String arg1, OfficeIMO.Excel.TableNameValidationMode arg2) #

Ensures a valid and unique table name according to OfficeIMO rules. Rules: - Allowed characters: letters, digits, underscore; spaces become underscores. - Names cannot start with a digit; an underscore is prefixed if necessary. - Names are scoped per workbook and checked case-insensitively. - When mode is Strict, throws for invalid input. Examples: - "My Table" ⇒ "My_Table" - "Sales#2025" ⇒ "Sales_2025" - "123Report" ⇒ "_123Report" - If "Table" already exists, next becomes "Table2" ("Table3", ...)

Parameters

arg1 System.String required
arg2 OfficeIMO.Excel.TableNameValidationMode required
EnsureWorksheetElementOrder() #

Ensures all worksheet elements are in the correct order according to OpenXML schema. This must be called before saving to prevent validation errors.

ExecuteWithPolicy(System.String opName, System.Int32 itemCount, System.Nullable{OfficeIMO.Excel.ExecutionMode} overrideMode, System.Action sequentialCore, System.Action computeParallel, System.Action applySequential, System.Threading.CancellationToken ct) #

Core execution helper that handles a compute/apply split with optional parallelization. Compute runs without locks; only the apply stage is serialized under a document-level lock.

Parameters

opName System.String required
A short operation name used for diagnostics and policy decisions.
itemCount System.Int32 required
Approximate number of items to process; used to decide parallel vs sequential. This does not have to be exact but should reflect relative workload.
overrideMode System.Nullable{OfficeIMO.Excel.ExecutionMode} required
Force a specific execution mode (Sequential/Parallel); null to use policy (Automatic).
sequentialCore System.Action required
Single-threaded path. Used either when policy decides sequential or when compute/apply are not provided.
computeParallel System.Action required
Compute phase that is safe to run without locks and must not mutate the OpenXML DOM.
applySequential System.Action required
Apply phase that writes to the DOM. This runs once under a serialized lock.
ct System.Threading.CancellationToken required
Cancellation token for the compute phase.
public String FindFirst(String text) #
Returns: String

Finds the first cell text that contains the specified value. Returns the A1 address or null. Searches values rendered as text (shared strings, inline strings, numbers as invariant strings).

Parameters

text System.String requiredposition: 0
public Void ForEachColumn(String a1, Action<Int32> action) #
Returns: Void

Iterates over column indices inside an A1 range and invokes action for each column.

Parameters

a1 System.String requiredposition: 0
A1 range without a sheet prefix.
action System.Action{System.Int32} requiredposition: 1
Callback receiving a 1-based column index.

Examples

sheet.ForEachRow("A2:A10", r => sheet.SetInternalLink(r, 1, "'Summary'!A1", "Back"));

public Void ForEachRow(String a1, Action<Int32> action) #
Returns: Void

Iterates over row indices inside an A1 range and invokes action for each row.

Parameters

a1 System.String requiredposition: 0
A1 range without a sheet prefix.
action System.Action{System.Int32} requiredposition: 1
Callback receiving a 1-based row index.

Examples

var bounds = sheet.GetRangeBounds("A2:D20"); // bounds.r1=2, bounds.c1=1, bounds.r2=20, bounds.c2=4

public Void FormatCell(Int32 row, Int32 column, String numberFormat) #
Returns: Void

Applies a number format to the specified cell.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index.
column System.Int32 requiredposition: 1
The 1-based column index.
numberFormat System.String requiredposition: 2
The number format code to apply.
public Void Freeze(Int32 topRows = 0, Int32 leftCols = 0) #
Returns: Void

Freezes panes on the worksheet.

Parameters

topRows System.Int32 = 0 optionalposition: 0
Number of rows at the top to freeze.
leftCols System.Int32 = 0 optionalposition: 1
Number of columns on the left to freeze.
public IReadOnlyDictionary<String, String> GetAllNamedRanges() #
Returns: IReadOnlyDictionary<String, String>

Returns all defined names visible to this sheet with their A1 ranges.

public ExcelChart GetChart(String name) #
Returns: ExcelChart

Returns a chart by name (non-visual name), or null if not found.

Parameters

name System.String requiredposition: 0
public HeaderFooterSnapshot GetHeaderFooter() #
Returns: HeaderFooterSnapshot

Returns a snapshot of the current header and footer strings (odd pages) split into left/center/right sections, including flags and whether a picture placeholder (&G) is present.

public Dictionary<String, Int32> GetHeaderMap(ExcelReadOptions options = null) #
Returns: Dictionary<String, Int32>

Builds or returns a cached case-insensitive map of header name to 1-based column index using the first row of UsedRange. Cache is keyed by UsedRange A1 and NormalizeHeaders option.

Parameters

options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 0
public String GetNamedRange(String name) #
Returns: String

Gets the A1 range for the given defined name, scoped to this sheet when applicable.

Parameters

name System.String requiredposition: 0
Defined name to resolve.

Returns

A1 range (e.g. "A1:B5") or null if not found.

public IReadOnlyList<ExcelPivotTableInfo> GetPivotTables() #
Returns: IReadOnlyList<ExcelPivotTableInfo>

Returns pivot tables defined on this worksheet.

public ValueTuple<Int32, Int32, Int32, Int32> GetRangeBounds(String a1) #
Returns: ValueTuple<Int32, Int32, Int32, Int32>

Parses an A1 range and returns 1-based bounds (r1, c1, r2, c2).

Parameters

a1 System.String requiredposition: 0
A1 range without a sheet prefix (e.g., "A2:D20").

Returns

Tuple of (r1, c1, r2, c2) with normalized bounds.

Exceptions

  • ArgumentException – Thrown when the input is not a valid A1 range.
public String GetUsedRangeA1() #
Returns: String

Returns the used range of this worksheet as an A1 string by leveraging the read bridge.

GuessLinkDisplay(System.String arg1) #

Parameters

arg1 System.String required

Examples

sheet.SetHyperlinkHost(7, 1, "https://learn.microsoft.com/office/open-xml/"); // displays "learn.microsoft.com"

public Boolean HasComment(Int32 row, Int32 column) #
Returns: Boolean

Returns true when a comment exists for the specified cell.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
public Void HeaderFooter(Action<HeaderFooterBuilder> configure) #
Returns: Void

Fluent header/footer configuration using the same builder as SheetComposer.

Parameters

configure System.Action{OfficeIMO.Excel.Fluent.HeaderFooterBuilder} requiredposition: 0
public Void HeaderLogoUrl(String url, HeaderFooterPosition position = Right, Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null, String leftText = null, String centerText = null, String rightText = null) #
Returns: Void

Convenience: sets a header logo from URL in the given position. Optional page text can be supplied.

Parameters

url System.String requiredposition: 0
position OfficeIMO.Excel.HeaderFooterPosition = Right optionalposition: 1
widthPoints System.Nullable{System.Double} = null optionalposition: 2
heightPoints System.Nullable{System.Double} = null optionalposition: 3
leftText System.String = null optionalposition: 4
centerText System.String = null optionalposition: 5
rightText System.String = null optionalposition: 6
public Void InsertDataTable(DataTable table, Int32 startRow = 1, Int32 startColumn = 1, Boolean includeHeaders = true, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void

Inserts a DataTable into the worksheet starting at the specified cell. Uses the batch CellValues compute/apply model with SharedString and Style planners.

Parameters

table System.Data.DataTable requiredposition: 0
Source DataTable.
startRow System.Int32 = 1 optionalposition: 1
1-based start row.
startColumn System.Int32 = 1 optionalposition: 2
1-based start column.
includeHeaders System.Boolean = true optionalposition: 3
Whether to write column headers.
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 4
Optional execution mode override.
ct System.Threading.CancellationToken = null optionalposition: 5
Cancellation token.
public String InsertDataTableAsTable(DataTable table, Int32 startRow = 1, Int32 startColumn = 1, Boolean includeHeaders = true, String tableName = null, TableStyle style = TableStyleMedium2, Boolean includeAutoFilter = true, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: String

Inserts a DataTable and immediately creates an Excel Table over the written range. Returns the A1-style range of the created table.

Parameters

table System.Data.DataTable requiredposition: 0
startRow System.Int32 = 1 optionalposition: 1
startColumn System.Int32 = 1 optionalposition: 2
includeHeaders System.Boolean = true optionalposition: 3
tableName System.String = null optionalposition: 4
style OfficeIMO.Excel.TableStyle = TableStyleMedium2 optionalposition: 5
includeAutoFilter System.Boolean = true optionalposition: 6
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 7
ct System.Threading.CancellationToken = null optionalposition: 8
public Void InsertObjects<T>(IEnumerable<T> items, Boolean includeHeaders, Int32 startRow, params ValueTuple<String, Func<T, Object>>[] columns) #
Returns: Void

Type Parameters

T

Parameters

items IEnumerable<T> requiredposition: 0
includeHeaders Boolean = true requiredposition: 1
startRow Int32 = 1 requiredposition: 2
InsertObjects``1 3 overloads
InsertObjects``1(System.Collections.Generic.IEnumerable{``0} items, System.Boolean includeHeaders, System.Int32 startRow) #

Inserts objects into the worksheet by flattening their properties into columns.

Type Parameters

T
Type of objects being inserted.

Parameters

items System.Collections.Generic.IEnumerable{``0} required
Collection of objects to insert.
includeHeaders System.Boolean required
Whether to include column headers.
startRow System.Int32 required
1-based starting row.
InsertObjects``1(System.Collections.Generic.IEnumerable{``0} items, System.ValueTuple{System.String,System.Func{``0,System.Object}}[] columns) #

Inserts objects into the worksheet using explicit column selectors (AOT-safe).

Type Parameters

T
Type of objects being inserted.

Parameters

items System.Collections.Generic.IEnumerable{``0} required
Collection of objects to insert.
columns System.ValueTuple{System.String,System.Func{``0,System.Object}}[] required
Column headers and selectors.
InsertObjects``1(System.Collections.Generic.IEnumerable{``0} items, System.Boolean includeHeaders, System.Int32 startRow, System.ValueTuple{System.String,System.Func{``0,System.Object}}[] columns) #

Inserts objects into the worksheet using explicit column selectors (AOT-safe).

Type Parameters

T
Type of objects being inserted.

Parameters

items System.Collections.Generic.IEnumerable{``0} required
Collection of objects to insert.
includeHeaders System.Boolean required
Whether to include column headers.
startRow System.Int32 required
1-based starting row.
columns System.ValueTuple{System.String,System.Func{``0,System.Object}}[] required
Column headers and selectors.
public Void LinkByHeaderToInternalSheets(String header, Int32 rowFrom = 2, Int32 rowTo = -1, Func<String, String> destinationSheetForCellText = null, String targetA1 = "A1", Func<String, String> display = null, Boolean styled = true) #
Returns: Void

Links a column identified by header to internal sheets using each cell's text. Defaults to linking to a sheet with the same name as the cell text. When the header is missing the operation is skipped.

Parameters

header System.String requiredposition: 0
Header text of the column to process.
rowFrom System.Int32 = 2 optionalposition: 1
First data row (1-based). Defaults to 2 (skip header).
rowTo System.Int32 = -1 optionalposition: 2
Last data row (inclusive). When <= 0, uses the bottom of the used range.
destinationSheetForCellText System.Func{System.String,System.String} = null optionalposition: 3
Maps cell text to a destination sheet name; defaults to identity.
targetA1 System.String = "A1" optionalposition: 4
Destination cell on the target sheet (default "A1").
display System.Func{System.String,System.String} = null optionalposition: 5
Optional display selector; defaults to the cell text.
styled System.Boolean = true optionalposition: 6
Apply hyperlink styling (blue + underline).
public Void LinkByHeaderToInternalSheetsInRange(String rangeA1, String header, Func<String, String> destinationSheetForCellText = null, String targetA1 = "A1", Func<String, String> display = null, Boolean styled = true) #
Returns: Void

Links a column identified by header within a rectangular A1 range to internal sheets. Uses the first row of the range as the header row and links rows r1+1..r2.

Parameters

rangeA1 System.String requiredposition: 0
A1 range (e.g., "A1:D50"). The first row is treated as the header row.
header System.String requiredposition: 1
Header text to match (case-insensitive).
destinationSheetForCellText System.Func{System.String,System.String} = null optionalposition: 2
Maps cell text to destination sheet name (defaults to identity).
targetA1 System.String = "A1" optionalposition: 3
Destination cell on the target sheet (default "A1").
display System.Func{System.String,System.String} = null optionalposition: 4
Optional display selector; defaults to the cell text.
styled System.Boolean = true optionalposition: 5
Apply hyperlink styling (blue + underline).
public Void LinkByHeaderToInternalSheetsInTable(String tableName, String header, Func<String, String> destinationSheetForCellText = null, String targetA1 = "A1", Func<String, String> display = null, Boolean styled = true) #
Returns: Void

Links a column within a table to internal sheets. The table range determines the row bounds.

Parameters

tableName System.String requiredposition: 0
Name of the table (as shown in Excel's Name Manager).
header System.String requiredposition: 1
Header text of the column inside the table.
destinationSheetForCellText System.Func{System.String,System.String} = null optionalposition: 2
Maps cell text to a destination sheet name (defaults to identity).
targetA1 System.String = "A1" optionalposition: 3
Destination cell on the target sheet (default "A1").
display System.Func{System.String,System.String} = null optionalposition: 4
Optional display selector; defaults to the cell text.
styled System.Boolean = true optionalposition: 5
Apply hyperlink styling (blue + underline).

Examples

// Internal: link "Domain" column to same-named sheets, rows 2..used bottom sheet.LinkByHeaderToInternalSheets("Domain"); // External: link "RFC" column to IETF datatracker pages sheet.LinkByHeaderToUrls("RFC", urlForCellText: rfc => $"https://datatracker.ietf.org/doc/html/{rfc}");

public Void LinkByHeaderToUrls(String header, Int32 rowFrom = 2, Int32 rowTo = -1, Func<String, String> urlForCellText = null, Func<String, String> titleForCellText = null, Boolean styled = true) #
Returns: Void

Links a column identified by header to external URLs built from each cell's text. When the header is missing the operation is skipped.

Parameters

header System.String requiredposition: 0
Header text of the column to process.
rowFrom System.Int32 = 2 optionalposition: 1
First data row (1-based). Defaults to 2 (skip header).
rowTo System.Int32 = -1 optionalposition: 2
Last data row (inclusive). When <= 0, uses the bottom of the used range.
urlForCellText System.Func{System.String,System.String} = null optionalposition: 3
Maps cell text to URL.
titleForCellText System.Func{System.String,System.String} = null optionalposition: 4
Optional display selector; when null, a smart display (RFC/host) is used.
styled System.Boolean = true optionalposition: 5
Apply hyperlink styling (blue + underline).
public Void LinkByHeaderToUrlsInRange(String rangeA1, String header, Func<String, String> urlForCellText, Func<String, String> titleForCellText = null, Boolean styled = true) #
Returns: Void

Links a column identified by header within a rectangular A1 range to external URLs. Uses the first row of the range as the header row and links rows r1+1..r2.

Parameters

rangeA1 System.String requiredposition: 0
A1 range (e.g., "A1:D50"). The first row is treated as the header row.
header System.String requiredposition: 1
Header text to match (case-insensitive).
urlForCellText System.Func{System.String,System.String} requiredposition: 2
Maps cell text to URL.
titleForCellText System.Func{System.String,System.String} = null optionalposition: 3
Optional display selector; when null, a smart display (RFC/host) is used.
styled System.Boolean = true optionalposition: 4
Apply hyperlink styling (blue + underline).
public Void LinkByHeaderToUrlsInTable(String tableName, String header, Func<String, String> urlForCellText, Func<String, String> titleForCellText = null, Boolean styled = true) #
Returns: Void

Links a column within a table to external URLs. The table range determines the row bounds.

Parameters

tableName System.String requiredposition: 0
Name of the table.
header System.String requiredposition: 1
Header text of the column inside the table.
urlForCellText System.Func{System.String,System.String} requiredposition: 2
Maps cell text to URL.
titleForCellText System.Func{System.String,System.String} = null optionalposition: 3
Optional display selector; when null, a smart display (RFC/host) is used.
styled System.Boolean = true optionalposition: 4
Apply hyperlink styling (blue + underline).
public Void LinkCellsToInternalSheets(String a1, Func<String, String> destinationSheetForCellText, String targetA1 = "A1", Func<String, String> display = null, Boolean styled = true) #
Returns: Void

Converts each non-empty cell in the A1 range into an internal hyperlink. The destination sheet name is computed from the cell's text using destinationSheetForCellText.

Parameters

a1 System.String requiredposition: 0
A1 range to process (e.g., a column of names).
destinationSheetForCellText System.Func{System.String,System.String} requiredposition: 1
Maps the cell text to a destination sheet name.
targetA1 System.String = "A1" optionalposition: 2
Destination cell on the target sheet (default "A1").
display System.Func{System.String,System.String} = null optionalposition: 3
Optional display text selector. Defaults to the cell text.
styled System.Boolean = true optionalposition: 4
When true, applies hyperlink styling (blue + underline).

Examples

sheet.ForEachColumn("A1:E1", c => sheet.CellBold(1, c, true));

Preflight() #

Removes empty containers and orphaned references on this worksheet to prevent Excel repairs.

public Void Protect(ExcelSheetProtectionOptions options = null) #
Returns: Void

Applies worksheet protection using the provided options.

Parameters

options OfficeIMO.Excel.ExcelSheetProtectionOptions = null optionalposition: 0
Protection options (defaults allow selection of locked/unlocked cells).
public Void RefreshHeaderCache(ExcelReadOptions options = null) #
Returns: Void

Forces rebuilding the header map for the current UsedRange and options.

Parameters

options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 0
public Boolean RemoveNamedRange(String name, Boolean save = true) #
Returns: Boolean

Removes a defined name scoped to this sheet.

Parameters

name System.String requiredposition: 0
Defined name to remove.
save System.Boolean = true optionalposition: 1
When true, saves the workbook after removal.

Returns

True if removed; false if not found.

public Int32 ReplaceAll(String oldText, String newText) #
Returns: Int32

Replaces all occurrences of oldText with newText in string cells. Returns the number of replacements performed.

Parameters

oldText System.String requiredposition: 0
newText System.String requiredposition: 1
Rows 2 overloads
public IEnumerable<Dictionary<String, Object>> Rows(ExcelReadOptions options = null) #
Returns: IEnumerable<Dictionary<String, Object>>

Reads the sheet's used range as a sequence of dictionaries using the first row as headers.

Parameters

options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 0
Optional read options/presets.
public IEnumerable<Dictionary<String, Object>> Rows(String a1Range, ExcelReadOptions options = null) #
Returns: IEnumerable<Dictionary<String, Object>>

Reads the specified A1 range as a sequence of dictionaries using the first row of the range as headers.

Parameters

a1Range System.String requiredposition: 0
Inclusive A1 range (e.g., "A1:C100").
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 1
Optional read options/presets.
public IEnumerable<T> RowsAs<T>(String a1Range, ExcelReadOptions options = null) #
Returns: IEnumerable<T>

Type Parameters

T

Parameters

a1Range String requiredposition: 0
options ExcelReadOptions = null optionalposition: 1
RowsAs``1(System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Maps the specified A1 range to a sequence of T using header-to-property mapping.

Parameters

a1Range System.String required
options OfficeIMO.Excel.ExcelReadOptions required
RowsObjects 2 overloads
public IEnumerable<RowEdit> RowsObjects(ExcelReadOptions options = null) #
Returns: IEnumerable<RowEdit>

Reads the sheet's used range as editable rows. First row is treated as headers.

Parameters

options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 0
public IEnumerable<RowEdit> RowsObjects(String a1Range, ExcelReadOptions options = null) #
Returns: IEnumerable<RowEdit>

Reads the specified A1 range as editable rows. First row is treated as headers.

Parameters

a1Range System.String requiredposition: 0
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 1
public Void SetByHeader(Int32 rowIndex, String header, Object value, ExcelReadOptions options = null) #
Returns: Void

Sets a cell value in the specified row by resolving the column using the header name. Does nothing when the header cannot be found.

Parameters

rowIndex System.Int32 requiredposition: 0
header System.String requiredposition: 1
value System.Object requiredposition: 2
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 3
public Void SetCellValues(IEnumerable<ValueTuple<Int32, Int32, Object>> cells, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: Void
Obsolete("Use CellValues(...) instead.")

Obsolete. Use CancellationToken) instead.

Parameters

cells System.Collections.Generic.IEnumerable{System.ValueTuple{System.Int32,System.Int32,System.Object}} requiredposition: 0
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 1
ct System.Threading.CancellationToken = null optionalposition: 2
public Void SetColumnHidden(Int32 columnIndex, Boolean hidden) #
Returns: Void

Hides or shows the specified column.

Parameters

columnIndex System.Int32 requiredposition: 0
1-based column index.
hidden System.Boolean requiredposition: 1
True to hide the column; false to show it.
public Void SetColumnWidth(Int32 columnIndex, Double width) #
Returns: Void

Sets the width of the specified column.

Parameters

columnIndex System.Int32 requiredposition: 0
1-based column index.
width System.Double requiredposition: 1
The column width.
SetComment 2 overloads
public Void SetComment(Int32 row, Int32 column, String text, String author = "OfficeIMO", String initials = null) #
Returns: Void

Adds or replaces a comment on the specified cell.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
text System.String requiredposition: 2
Comment text.
author System.String = "OfficeIMO" optionalposition: 3
Author name (optional).
initials System.String = null optionalposition: 4
Author initials (optional).
public Void SetComment(String a1, String text, String author = "OfficeIMO", String initials = null) #
Returns: Void

Adds or replaces a comment on the specified A1 cell reference.

Parameters

a1 System.String requiredposition: 0
A1 cell reference (e.g., "B5").
text System.String requiredposition: 1
Comment text.
author System.String = "OfficeIMO" optionalposition: 2
Author name (optional).
initials System.String = null optionalposition: 3
Author initials (optional).
public Void SetFooterImage(HeaderFooterPosition position, Byte[] imageBytes, String contentType = "image/png", Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null) #
Returns: Void

Adds an image to the worksheet footer at the given position. This will also ensure the footer text contains the picture placeholder (&G) in the corresponding section. Subsequent calls replace any previously set header/footer images for this sheet.

Parameters

position OfficeIMO.Excel.HeaderFooterPosition requiredposition: 0
imageBytes System.Byte[] requiredposition: 1
contentType System.String = "image/png" optionalposition: 2
widthPoints System.Nullable{System.Double} = null optionalposition: 3
heightPoints System.Nullable{System.Double} = null optionalposition: 4
public Void SetFooterImageUrl(HeaderFooterPosition position, String url, Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null) #
Returns: Void

Downloads an image from URL and sets it in the footer at the given position (convenience wrapper).

Parameters

position OfficeIMO.Excel.HeaderFooterPosition requiredposition: 0
url System.String requiredposition: 1
widthPoints System.Nullable{System.Double} = null optionalposition: 2
heightPoints System.Nullable{System.Double} = null optionalposition: 3
public Void SetGridlinesVisible(Boolean visible) #
Returns: Void

Shows or hides gridlines on the current sheet (view-level setting).

Parameters

visible System.Boolean requiredposition: 0
public Void SetHeaderFooter(String headerLeft = null, String headerCenter = null, String headerRight = null, String footerLeft = null, String footerCenter = null, String footerRight = null, Boolean differentFirstPage = false, Boolean differentOddEven = false, Boolean alignWithMargins = true, Boolean scaleWithDoc = true) #
Returns: Void

Sets the header and/or footer text for this worksheet.

Parameters

headerLeft System.String = null optionalposition: 0
Left header text (optional).
headerCenter System.String = null optionalposition: 1
Center header text (optional).
headerRight System.String = null optionalposition: 2
Right header text (optional).
footerLeft System.String = null optionalposition: 3
Left footer text (optional).
footerCenter System.String = null optionalposition: 4
Center footer text (optional).
footerRight System.String = null optionalposition: 5
Right footer text (optional).
differentFirstPage System.Boolean = false optionalposition: 6
Use a different header/footer on the first page.
differentOddEven System.Boolean = false optionalposition: 7
Use different headers/footers for odd and even pages.
alignWithMargins System.Boolean = true optionalposition: 8
Align header/footer with page margins.
scaleWithDoc System.Boolean = true optionalposition: 9
Scale header/footer with document scaling.
public Void SetHeaderImage(HeaderFooterPosition position, Byte[] imageBytes, String contentType = "image/png", Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null) #
Returns: Void

Adds an image to the worksheet header at the given position. This will also ensure the header text contains the picture placeholder (&G) in the corresponding section. Subsequent calls replace any previously set header/footer images for this sheet.

Parameters

position OfficeIMO.Excel.HeaderFooterPosition requiredposition: 0
Left, Center, or Right header section.
imageBytes System.Byte[] requiredposition: 1
Image bytes.
contentType System.String = "image/png" optionalposition: 2
e.g. image/png, image/jpeg. Defaults to image/png.
widthPoints System.Nullable{System.Double} = null optionalposition: 3
Optional width in points. If omitted, inferred from image size at 96 DPI.
heightPoints System.Nullable{System.Double} = null optionalposition: 4
Optional height in points. If omitted, inferred proportionally.
public Void SetHeaderImageUrl(HeaderFooterPosition position, String url, Nullable<Double> widthPoints = null, Nullable<Double> heightPoints = null) #
Returns: Void

Downloads an image from URL and sets it in the header at the given position (convenience wrapper).

Parameters

position OfficeIMO.Excel.HeaderFooterPosition requiredposition: 0
url System.String requiredposition: 1
widthPoints System.Nullable{System.Double} = null optionalposition: 2
heightPoints System.Nullable{System.Double} = null optionalposition: 3
public Void SetHidden(Boolean hidden) #
Returns: Void

Hides or shows the worksheet in the workbook.

Parameters

hidden System.Boolean requiredposition: 0
SetHyperlink 2 overloads
public Void SetHyperlinkHost(Int32 row, Int32 column, String url, Boolean style = true) #
Returns: Void

Creates an external hyperlink showing only the host (e.g., example.org) as display text.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
url System.String requiredposition: 2
Target URL.
style System.Boolean = true optionalposition: 3
When true, applies hyperlink styling (blue + underline).

Examples

sheet.SetHyperlinkSmart(5, 1, "https://datatracker.ietf.org/doc/html/rfc7208"); // displays "RFC 7208" sheet.SetHyperlinkSmart(6, 1, "https://example.org/path", title: "Spec"); // displays "Spec"

public Void SetHyperlinkSmart(Int32 row, Int32 column, String url, String title = null, Boolean style = true) #
Returns: Void

Creates an external hyperlink using a smart display strategy: prefer title, then an RFC label (e.g., "RFC 7208") when detected, otherwise the URL host.

Parameters

row System.Int32 requiredposition: 0
1-based row index.
column System.Int32 requiredposition: 1
1-based column index.
url System.String requiredposition: 2
Target URL.
title System.String = null optionalposition: 3
Optional preferred display text.
style System.Boolean = true optionalposition: 4
When true, applies hyperlink styling (blue + underline).

Examples

// Given a summary table where column A contains sheet names, link each cell to its sheet sheet.LinkCellsToInternalSheets("A2:A51", text => text, targetA1: "A1", styled: true);

SetInternalLink 2 overloads
public Void SetMargins(Double left, Double right, Double top, Double bottom, Double header = 0.3, Double footer = 0.3) #
Returns: Void

Sets page margins in inches.

Parameters

left System.Double requiredposition: 0
right System.Double requiredposition: 1
top System.Double requiredposition: 2
bottom System.Double requiredposition: 3
header System.Double = 0.3 optionalposition: 4
footer System.Double = 0.3 optionalposition: 5
public Void SetMarginsPreset(ExcelMarginPreset preset) #
Returns: Void

Applies a preset set of margins.

Parameters

preset OfficeIMO.Excel.ExcelMarginPreset requiredposition: 0
SetNamedRange 2 overloads
public Void SetNamedRange(String name, String range, Boolean save = true, Boolean hidden = false) #
Returns: Void

Creates or updates a named range in the workbook, scoped to this sheet.

Parameters

name System.String requiredposition: 0
Defined name to create or update.
range System.String requiredposition: 1
A1 range (e.g. "A1:B5").
save System.Boolean = true optionalposition: 2
When true, saves the workbook after the change.
hidden System.Boolean = false optionalposition: 3
When true, marks the defined name as hidden.
public Void SetNamedRange(String name, String range, Boolean save, Boolean hidden, NameValidationMode validationMode) #
Returns: Void

Creates or updates a named range in the workbook, scoped to this sheet, with validation control.

Parameters

name System.String requiredposition: 0
Defined name to create or update.
range System.String requiredposition: 1
A1 range (e.g. "A1:B5").
save System.Boolean requiredposition: 2
When true, saves the workbook after the change.
hidden System.Boolean requiredposition: 3
When true, marks the defined name as hidden.
validationMode OfficeIMO.Excel.NameValidationMode requiredposition: 4
Controls how the name and range are validated: Sanitize (default) clamps/adjusts; Strict throws on invalid input.
public Void SetOrientation(ExcelPageOrientation orientation) #
Returns: Void

Sets page orientation (Portrait or Landscape) on the sheet's PageSetup.

Parameters

orientation OfficeIMO.Excel.ExcelPageOrientation requiredposition: 0
public Void SetPageSetup(Nullable<UInt32> fitToWidth = null, Nullable<UInt32> fitToHeight = null, Nullable<UInt32> scale = null) #
Returns: Void

Configures basic print/page setup for the sheet.

Parameters

fitToWidth System.Nullable{System.UInt32} = null optionalposition: 0
Number of pages to fit horizontally (1 = fit to one page).
fitToHeight System.Nullable{System.UInt32} = null optionalposition: 1
Number of pages to fit vertically (0 = unlimited).
scale System.Nullable{System.UInt32} = null optionalposition: 2
Manual scale (10-400). Ignored if FitToWidth/Height are specified.
public Void SetTableTotals(String range, Dictionary<String, TotalsRowFunctionValues> byHeader) #
Returns: Void

Enables a totals row for the table covering range and assigns per-column functions by header name. Supported functions are those in TotalsRowFunctionValues (Sum, Average, Count, Min, Max, etc.).

Parameters

range System.String requiredposition: 0
Address of the table range (for example, "A1:D10") whose totals row should be displayed.
byHeader System.Collections.Generic.Dictionary{System.String,DocumentFormat.OpenXml.Spreadsheet.TotalsRowFunctionValues} requiredposition: 1
Mapping of table header names to the totals function that should be applied for each column.
public Void SortUsedRangeByHeader(String header, Boolean ascending = true) #
Returns: Void

Sorts the sheet's UsedRange rows in-place (excluding header) by the column resolved via header. Values-only: rewrites cell values; formulas and styles are not preserved. When the header cannot be resolved the sort is skipped.

Parameters

header System.String requiredposition: 0
ascending System.Boolean = true optionalposition: 1
public Void SortUsedRangeByHeaders(params ValueTuple<String, Boolean>[] keys) #
Returns: Void

Sorts the sheet's UsedRange rows in-place by multiple headers in the given order (excluding header row). Values-only: rewrites cell values; formulas and styles are not preserved. Missing headers are ignored and when no valid headers remain the sort is skipped.

Parameters

keys System.ValueTuple{System.String,System.Boolean}[] requiredposition: 0
public Boolean TryGetCellText(Int32 row, Int32 column, out String text) #
Returns: Boolean

Tries to read the display text of a cell at the given position. Returns false if the cell is blank or out of bounds.

Parameters

row System.Int32 requiredposition: 0
The 1-based row index of the cell to inspect.
column System.Int32 requiredposition: 1
The 1-based column index of the cell to inspect.
text System.String@ requiredposition: 2
When this method returns, contains the extracted cell text if successful; otherwise, an empty string.

Returns

true if text was read successfully; otherwise, false.

public Boolean TryGetColumnIndexByHeader(String header, out Int32 columnIndex, ExcelReadOptions options = null) #
Returns: Boolean

Tries to resolve a 1-based column index for a given header. Returns false without throwing when the header cannot be found.

Parameters

header System.String requiredposition: 0
columnIndex System.Int32@ requiredposition: 1
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 2
public Boolean TryLinkByHeaderToInternalSheets(String header, Int32 rowFrom = 2, Int32 rowTo = -1, Func<String, String> destinationSheetForCellText = null, String targetA1 = "A1", Func<String, String> display = null, Boolean styled = true) #
Returns: Boolean

Non-throwing variant of Boolean). Returns false when the header cannot be found or inputs are invalid.

Parameters

header System.String requiredposition: 0
rowFrom System.Int32 = 2 optionalposition: 1
rowTo System.Int32 = -1 optionalposition: 2
destinationSheetForCellText System.Func{System.String,System.String} = null optionalposition: 3
targetA1 System.String = "A1" optionalposition: 4
display System.Func{System.String,System.String} = null optionalposition: 5
styled System.Boolean = true optionalposition: 6
public Boolean TryLinkByHeaderToInternalSheetsInRange(String rangeA1, String header, String targetA1 = "A1", Func<String, String> destinationSheetForCellText = null, Func<String, String> display = null, Boolean styled = true) #
Returns: Boolean

Non-throwing variant of Boolean). Returns false when the range cannot be parsed or the header is missing.

Parameters

rangeA1 System.String requiredposition: 0
header System.String requiredposition: 1
targetA1 System.String = "A1" optionalposition: 2
destinationSheetForCellText System.Func{System.String,System.String} = null optionalposition: 3
display System.Func{System.String,System.String} = null optionalposition: 4
styled System.Boolean = true optionalposition: 5
public Boolean TryLinkByHeaderToInternalSheetsInTable(String tableName, String header, Func<String, String> destinationSheetForCellText = null, String targetA1 = "A1", Func<String, String> display = null, Boolean styled = true) #
Returns: Boolean

Non-throwing variant of Boolean). Returns false when the table or header cannot be found.

Parameters

tableName System.String requiredposition: 0
header System.String requiredposition: 1
destinationSheetForCellText System.Func{System.String,System.String} = null optionalposition: 2
targetA1 System.String = "A1" optionalposition: 3
display System.Func{System.String,System.String} = null optionalposition: 4
styled System.Boolean = true optionalposition: 5
public Boolean TryLinkByHeaderToUrls(String header, Int32 rowFrom = 2, Int32 rowTo = -1, Func<String, String> urlForCellText = null, Func<String, String> titleForCellText = null, Boolean styled = true) #
Returns: Boolean

Non-throwing variant of Boolean). Returns false when the header cannot be found or inputs are invalid.

Parameters

header System.String requiredposition: 0
rowFrom System.Int32 = 2 optionalposition: 1
rowTo System.Int32 = -1 optionalposition: 2
urlForCellText System.Func{System.String,System.String} = null optionalposition: 3
titleForCellText System.Func{System.String,System.String} = null optionalposition: 4
styled System.Boolean = true optionalposition: 5
public Boolean TryLinkByHeaderToUrlsInRange(String rangeA1, String header, Func<String, String> urlForCellText, Func<String, String> titleForCellText = null, Boolean styled = true) #
Returns: Boolean

Non-throwing variant of Boolean). Returns false when the range cannot be parsed or the header is missing.

Parameters

rangeA1 System.String requiredposition: 0
header System.String requiredposition: 1
urlForCellText System.Func{System.String,System.String} requiredposition: 2
titleForCellText System.Func{System.String,System.String} = null optionalposition: 3
styled System.Boolean = true optionalposition: 4
public Boolean TryLinkByHeaderToUrlsInTable(String tableName, String header, Func<String, String> urlForCellText, Func<String, String> titleForCellText = null, Boolean styled = true) #
Returns: Boolean

Non-throwing variant of Boolean). Returns false when the table or header cannot be found.

Parameters

tableName System.String requiredposition: 0
header System.String requiredposition: 1
urlForCellText System.Func{System.String,System.String} requiredposition: 2
titleForCellText System.Func{System.String,System.String} = null optionalposition: 3
styled System.Boolean = true optionalposition: 4
public Void Unprotect() #
Returns: Void

Removes worksheet protection.

UpdateSheetDimension() #

Updates the SheetDimension element to reflect the current used range. Helps avoid rare "dimension" repair messages in Excel when generating sheets programmatically.

public Void ValidationCustomFormula(String a1Range, String formula, Boolean allowBlank = true, String errorTitle = null, String errorMessage = null) #
Returns: Void

Applies a custom formula validation to the specified A1 range.

Parameters

a1Range System.String requiredposition: 0
formula System.String requiredposition: 1
allowBlank System.Boolean = true optionalposition: 2
errorTitle System.String = null optionalposition: 3
errorMessage System.String = null optionalposition: 4
public Void ValidationDate(String a1Range, DataValidationOperatorValues operator, DateTime formula1, Nullable<DateTime> formula2 = null, Boolean allowBlank = true, String errorTitle = null, String errorMessage = null) #
Returns: Void

Applies a date validation to the specified A1 range.

Parameters

a1Range System.String requiredposition: 0
operator DocumentFormat.OpenXml.Spreadsheet.DataValidationOperatorValues requiredposition: 1
formula1 System.DateTime requiredposition: 2
formula2 System.Nullable{System.DateTime} = null optionalposition: 3
allowBlank System.Boolean = true optionalposition: 4
errorTitle System.String = null optionalposition: 5
errorMessage System.String = null optionalposition: 6
public Void ValidationDecimal(String a1Range, DataValidationOperatorValues operator, Double formula1, Nullable<Double> formula2 = null, Boolean allowBlank = true, String errorTitle = null, String errorMessage = null) #
Returns: Void

Applies a decimal number validation to the specified A1 range.

Parameters

a1Range System.String requiredposition: 0
operator DocumentFormat.OpenXml.Spreadsheet.DataValidationOperatorValues requiredposition: 1
formula1 System.Double requiredposition: 2
formula2 System.Nullable{System.Double} = null optionalposition: 3
allowBlank System.Boolean = true optionalposition: 4
errorTitle System.String = null optionalposition: 5
errorMessage System.String = null optionalposition: 6
public Void ValidationList(String a1Range, IEnumerable<String> items, Boolean allowBlank = true) #
Returns: Void

Applies a list validation to the specified A1 range using explicit items.

Parameters

a1Range System.String requiredposition: 0
items System.Collections.Generic.IEnumerable{System.String} requiredposition: 1
allowBlank System.Boolean = true optionalposition: 2
public Void ValidationListNamedRange(String a1Range, String namedRange, Boolean allowBlank = true) #
Returns: Void

Applies a list validation to the specified A1 range using a workbook or sheet-local named range.

Parameters

a1Range System.String requiredposition: 0
namedRange System.String requiredposition: 1
allowBlank System.Boolean = true optionalposition: 2
public Void ValidationListRange(String a1Range, String sourceA1Range, String sourceSheetName = null, Boolean allowBlank = true) #
Returns: Void

Applies a list validation to the specified A1 range using a referenced worksheet range. When sourceSheetName is omitted, the current worksheet is used.

Parameters

a1Range System.String requiredposition: 0
sourceA1Range System.String requiredposition: 1
sourceSheetName System.String = null optionalposition: 2
allowBlank System.Boolean = true optionalposition: 3
public Void ValidationTextLength(String a1Range, DataValidationOperatorValues operator, Int32 formula1, Nullable<Int32> formula2 = null, Boolean allowBlank = true, String errorTitle = null, String errorMessage = null) #
Returns: Void

Applies a text length validation to the specified A1 range.

Parameters

a1Range System.String requiredposition: 0
operator DocumentFormat.OpenXml.Spreadsheet.DataValidationOperatorValues requiredposition: 1
formula1 System.Int32 requiredposition: 2
formula2 System.Nullable{System.Int32} = null optionalposition: 3
allowBlank System.Boolean = true optionalposition: 4
errorTitle System.String = null optionalposition: 5
errorMessage System.String = null optionalposition: 6
public Void ValidationTime(String a1Range, DataValidationOperatorValues operator, TimeSpan formula1, Nullable<TimeSpan> formula2 = null, Boolean allowBlank = true, String errorTitle = null, String errorMessage = null) #
Returns: Void

Applies a time validation to the specified A1 range.

Parameters

a1Range System.String requiredposition: 0
operator DocumentFormat.OpenXml.Spreadsheet.DataValidationOperatorValues requiredposition: 1
formula1 System.TimeSpan requiredposition: 2
formula2 System.Nullable{System.TimeSpan} = null optionalposition: 3
allowBlank System.Boolean = true optionalposition: 4
errorTitle System.String = null optionalposition: 5
errorMessage System.String = null optionalposition: 6
public Void ValidationWholeNumber(String a1Range, DataValidationOperatorValues operator, Int32 formula1, Nullable<Int32> formula2 = null, Boolean allowBlank = true, String errorTitle = null, String errorMessage = null) #
Returns: Void

Applies a whole number validation to the specified A1 range.

Parameters

a1Range System.String requiredposition: 0
operator DocumentFormat.OpenXml.Spreadsheet.DataValidationOperatorValues requiredposition: 1
formula1 System.Int32 requiredposition: 2
formula2 System.Nullable{System.Int32} = null optionalposition: 3
allowBlank System.Boolean = true optionalposition: 4
errorTitle System.String = null optionalposition: 5
errorMessage System.String = null optionalposition: 6
WrapCells 2 overloads
public Void WrapCells(Int32 fromRow, Int32 toRow, Int32 column) #
Returns: Void

Enables WrapText for every cell in a column within a given row range.

Parameters

fromRow System.Int32 requiredposition: 0
The first 1-based row index in the range.
toRow System.Int32 requiredposition: 1
The last 1-based row index in the range.
column System.Int32 requiredposition: 2
The 1-based column index whose cells should wrap.
public Void WrapCells(Int32 fromRow, Int32 toRow, Int32 column, Double targetColumnWidth) #
Returns: Void

Enables WrapText for the specified column and pins the target column width (in Excel character units). Useful when mixed with auto-fit operations so wrapped columns keep a predictable width.

Parameters

fromRow System.Int32 requiredposition: 0
The first 1-based row index in the range.
toRow System.Int32 requiredposition: 1
The last 1-based row index in the range.
column System.Int32 requiredposition: 2
The 1-based column index whose cells should wrap.
targetColumnWidth System.Double requiredposition: 3
The column width, in Excel character units, to enforce when wrapping.
public ExcelChartDataRange WriteChartData(ExcelChartData data, Int32 startRow = 1, Int32 startColumn = 1, String categoryHeader = null, Boolean includeHeaderRow = true, Boolean numericCategories = false) #
Returns: ExcelChartDataRange

Writes chart data into the worksheet and returns the corresponding data range.

Parameters

data OfficeIMO.Excel.ExcelChartData requiredposition: 0
startRow System.Int32 = 1 optionalposition: 1
startColumn System.Int32 = 1 optionalposition: 2
categoryHeader System.String = null optionalposition: 3
includeHeaderRow System.Boolean = true optionalposition: 4
numericCategories System.Boolean = false optionalposition: 5

Properties

public IEnumerable<ExcelChart> Charts { get; } #

Enumerates charts on the worksheet.

public String Name { get; set; } #

Gets or sets the worksheet name.

public ExecutionPolicy ExecutionOverride { get; set; } #

Override execution policy for this sheet. Null = inherit from document.

EffectiveExecution #

Gets the effective execution policy for this sheet.

public Boolean IsProtected { get; } #

Gets whether the worksheet is protected.

public String UsedRangeA1 { get; } #

Returns the used range A1 address for this sheet. Alias property for API ergonomics.