# ExcelRange

Lightweight object model wrapper for an A1 range: a cell, a rectangle, whole rows or columns, or a list of such areas separated by spaces or commas.

Class 

`OfficeIMO.Excel`

**Namespace**

`OfficeIMO.Excel`

**Assembly**

`OfficeIMO.Excel`

**Source revision**

`273d35d5ba8a` with working tree changes

**Source**

[ExcelRange.Values.cs:6](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRange.Values.cs#L6)

**Modifiers**

sealed

Lightweight object model wrapper for an A1 range: a cell, a rectangle, whole rows or columns, or a list of such areas separated by spaces or commas.

## Inheritance

- object
- ExcelRange

## Remarks

A range with several areas formats every cell of every area and carries its conditional formatting and data validation as one rule. Operations that need one rectangle, such as merging, copying, sorting, tables, values and AutoFilter, throw for it.

## Guides & Samples

Authored walkthroughs and practical samples linked to this API.

- [Worksheets](/docs/excel/worksheets/) Guide
  
  Working with Excel worksheets in OfficeIMO.Excel — cells, formatting, formulas, and named ranges. Includes examples and API links.

## Usage

Explore 42 API references to this type

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

### Returned or exposed by 42

- Method [ExcelDocument.GetNamedRange](/api/excel/officeimo-excel-exceldocument/#method-getnamedrange-string-officeimo-excel-excelsheet)
- Method [ExcelRange.Clear](/api/excel/officeimo-excel-excelrange/#method-clear-officeimo-excel-excelclearoptions)
- Method [ExcelRange.Merge](/api/excel/officeimo-excel-excelrange/#method-merge)
- Method [ExcelRange.SetBaseline](/api/excel/officeimo-excel-excelrange/#method-setbaseline)
- Method [ExcelRange.SetBold](/api/excel/officeimo-excel-excelrange/#method-setbold-boolean)
- Method [ExcelRange.SetBorder](/api/excel/officeimo-excel-excelrange/#method-setborder-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor)
- Method [ExcelRange.SetColor](/api/excel/officeimo-excel-excelrange/#method-setcolor-officeimo-officecolor)
- Method [ExcelRange.SetDiagonalBorder](/api/excel/officeimo-excel-excelrange/#method-setdiagonalborder-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor-boolean-boolean)
- Method [ExcelRange.SetFillColor](/api/excel/officeimo-excel-excelrange/#method-setfillcolor-officeimo-officecolor)
- Method [ExcelRange.SetFontFamily](/api/excel/officeimo-excel-excelrange/#method-setfontfamily-string)
- Method [ExcelRange.SetFontSize](/api/excel/officeimo-excel-excelrange/#method-setfontsize-officeimo-officelength)
- Method [ExcelRange.SetGradientFill](/api/excel/officeimo-excel-excelrange/#method-setgradientfill-officeimo-officecolor-officeimo-officecolor-double)
- Method [ExcelRange.SetHorizontalAlignment](/api/excel/officeimo-excel-excelrange/#method-sethorizontalalignment-officeimo-excel-excelhorizontalalignment)
- Method [ExcelRange.SetItalic](/api/excel/officeimo-excel-excelrange/#method-setitalic-boolean)
- Method [ExcelRange.SetNumberFormat](/api/excel/officeimo-excel-excelrange/#method-setnumberformat-string)
- Method [ExcelRange.SetShrinkToFit](/api/excel/officeimo-excel-excelrange/#method-setshrinktofit-boolean)
- Method [ExcelRange.SetStrikethrough](/api/excel/officeimo-excel-excelrange/#method-setstrikethrough-boolean)
- Method [ExcelRange.SetSubscript](/api/excel/officeimo-excel-excelrange/#method-setsubscript)
- Method [ExcelRange.SetSuperscript](/api/excel/officeimo-excel-excelrange/#method-setsuperscript)
- Method [ExcelRange.SetTextRotation](/api/excel/officeimo-excel-excelrange/#method-settextrotation-int32)
- Method [ExcelRange.SetUnderline](/api/excel/officeimo-excel-excelrange/#method-setunderline-boolean)
- Method [ExcelRange.SetValues](/api/excel/officeimo-excel-excelrange/#method-setvalues-object-0-0)
- Method [ExcelRange.SetVerticalAlignment](/api/excel/officeimo-excel-excelrange/#method-setverticalalignment-officeimo-excel-excelverticalalignment)
- Method [ExcelRange.SetVerticalTextAlignment](/api/excel/officeimo-excel-excelrange/#method-setverticaltextalignment-officeimo-excel-excelverticaltextalignment)
- Method [ExcelRange.SetWrapText](/api/excel/officeimo-excel-excelrange/#method-setwraptext-boolean)
- Method [ExcelRange.SortByColumn](/api/excel/officeimo-excel-excelrange/#method-sortbycolumn-int32-boolean-boolean)
- Method [ExcelRange.TransformTextCase](/api/excel/officeimo-excel-excelrange/#method-transformtextcase-officeimo-drawing-officetextcase-globalization-cultureinfo)
- Method [ExcelRange.Unmerge](/api/excel/officeimo-excel-excelrange/#method-unmerge)
- Method [ExcelRangeDataValidationBuilder.CustomFormula](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-customformula-string-boolean-string-string)
- Method [ExcelRangeDataValidationBuilder.Date](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-date-officeimo-excel-exceldatavalidationoperator-datetime-nullable-system-datetime-boolean-string-string)
- Method [ExcelRangeDataValidationBuilder.Decimal](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-decimal-officeimo-excel-exceldatavalidationoperator-double-nullable-system-double-boolean-string-string)
- Method [ExcelRangeDataValidationBuilder.List](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-list-collections-generic-ienumerable-system-string-boolean)
- Method [ExcelRangeDataValidationBuilder.ListNamedRange](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-listnamedrange-string-boolean)
- Method [ExcelRangeDataValidationBuilder.ListRange](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-listrange-string-string-boolean)
- Method [ExcelRangeDataValidationBuilder.TextLength](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-textlength-officeimo-excel-exceldatavalidationoperator-int32-nullable-system-int32-boolean-string-string)
- Method [ExcelRangeDataValidationBuilder.Time](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-time-officeimo-excel-exceldatavalidationoperator-timespan-nullable-system-timespan-boolean-string-string)
- Method [ExcelRangeDataValidationBuilder.WholeNumber](/api/excel/officeimo-excel-excelrangedatavalidationbuilder/#method-wholenumber-officeimo-excel-exceldatavalidationoperator-int32-nullable-system-int32-boolean-string-string)
- Method [ExcelSheet.GetNamedRange](/api/excel/officeimo-excel-excelsheet/#method-getnamedrange-string)
- Method [ExcelSheet.Range](/api/excel/officeimo-excel-excelsheet/#method-range-string)
- Property [ExcelSheet.UsedRange](/api/excel/officeimo-excel-excelsheet/#property-usedrange)
- Method [ExcelTable.AsRange](/api/excel/officeimo-excel-exceltable/#method-asrange)
- Method [ExcelTable.Column](/api/excel/officeimo-excel-exceltable/#method-column-string-boolean-boolean)

Filter members 

Show inherited

## Methods

`public ExcelAutoFilter AutoFilter()` [#](#method-autofilter)

[ExcelCell.cs:432](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L432)

Returns the AutoFilter on this range, creating it when the range has none. An existing filter on the same range keeps its criteria; a worksheet filter on another range is replaced. A table on the same range owns the filter.

Returns

`ExcelAutoFilter`

`public ExcelCell Cell(int rowOffset, int columnOffset)` [#](#method-cell-int32-int32)

[ExcelRange.Values.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRange.Values.cs#L21)

Gets an editable cell using one-based offsets from this range's top-left cell.

Parameters

**rowOffset int required**

**columnOffset int required**

Returns

`ExcelCell`

`public ExcelRange Clear(ExcelClearOptions options = All)` [#](#method-clear-officeimo-excel-excelclearoptions)

[ExcelCell.cs:440](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L440)

Clears selected data and metadata from the range.

Parameters

**options OfficeIMO.Excel.ExcelClearOptions = All optional**

Returns

`ExcelRange`

`public ExcelRangeConditionalFormattingBuilder ConditionalFormat()` [#](#method-conditionalformat)

[ExcelCell.cs:424](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L424)

Adds conditional formatting rules to the range.

Returns

`ExcelRangeConditionalFormattingBuilder`

`public ExcelMutationResult CopyTo(string destinationTopLeft, ExcelMutationPlanOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-copyto-string-officeimo-excel-excelmutationplanoptions-threading-cancellationtoken)

[ExcelCell.cs:462](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L462)

Copies this range to a destination top-left cell.

Parameters

**destinationTopLeft string required**

**options OfficeIMO.Excel.ExcelMutationPlanOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`ExcelMutationResult`

`public ExcelTable CreateTable(string name, bool hasHeader = true, ExcelTableStyle style = TableStyleMedium2, bool includeAutoFilter = true)` [#](#method-createtable-string-boolean-officeimo-excel-exceltablestyle-boolean)

[ExcelCell.cs:492](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L492)

Creates an Excel table over the range.

Parameters

**name string required**

**hasHeader bool = true optional**

**style OfficeIMO.Excel.ExcelTableStyle = TableStyleMedium2 optional**

**includeAutoFilter bool = true optional**

Returns

`ExcelTable`

`public ExcelRangeVisualInfo CreateVisualSnapshot(ExcelImageExportOptions? options = null)` [#](#method-createvisualsnapshot-officeimo-excel-excelimageexportoptions)

[ExcelRange.Imaging.cs:10](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/Imaging/ExcelRange.Imaging.cs#L10)

Creates a format-neutral visual snapshot for this range.

Parameters

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

Returns

`ExcelRangeVisualInfo`

`public ExcelMutationResult Delete(ExcelCellShiftDirection direction, ExcelMutationPlanOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-delete-officeimo-excel-excelcellshiftdirection-officeimo-excel-excelmutationplanoptions-threading-cancellationtoken)

[ExcelCell.cs:458](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L458)

Transactionally deletes this cell block.

Parameters

**direction OfficeIMO.Excel.ExcelCellShiftDirection required**

**options OfficeIMO.Excel.ExcelMutationPlanOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`ExcelMutationResult`

`public ExcelMutationResult Insert(ExcelCellShiftDirection direction, ExcelMutationPlanOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-insert-officeimo-excel-excelcellshiftdirection-officeimo-excel-excelmutationplanoptions-threading-cancellationtoken)

[ExcelCell.cs:454](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L454)

Transactionally inserts a cell block at this range.

Parameters

**direction OfficeIMO.Excel.ExcelCellShiftDirection required**

**options OfficeIMO.Excel.ExcelMutationPlanOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`ExcelMutationResult`

`public ExcelRange Merge()` [#](#method-merge)

[ExcelCell.cs:476](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L476)

Merges the range.

Returns

`ExcelRange`

`public ExcelMutationResult MoveTo(string destinationTopLeft, ExcelMutationPlanOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-moveto-string-officeimo-excel-excelmutationplanoptions-threading-cancellationtoken)

[ExcelCell.cs:466](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L466)

Moves this range to a destination top-left cell.

Parameters

**destinationTopLeft string required**

**options OfficeIMO.Excel.ExcelMutationPlanOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`ExcelMutationResult`

SaveAsImage 2 overloads

`public OfficeConversionReport SaveAsImage(string path, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasimage-string-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

[ExcelRange.Imaging.Conversion.cs:34](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/Imaging/ExcelRange.Imaging.Conversion.cs#L34)

Writes the range to a file and returns its fidelity report.

Parameters

**path string required**

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OfficeConversionReport`

`public OfficeConversionReport SaveAsImage(Stream stream, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasimage-io-stream-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

[ExcelRange.Imaging.Conversion.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/Imaging/ExcelRange.Imaging.Conversion.cs#L44)

Writes the range to a caller-owned stream and returns its fidelity report.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OfficeConversionReport`

SaveAsImageAsync 2 overloads

`public async Task<OfficeConversionReport> SaveAsImageAsync(string path, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasimageasync-string-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

Asynchronously writes the range to a file and returns its fidelity report.

Parameters

**path string required**

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<OfficeConversionReport>`

`public async Task<OfficeConversionReport> SaveAsImageAsync(Stream stream, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-saveasimageasync-io-stream-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

Asynchronously writes the range to a caller-owned stream and returns its fidelity report.

Parameters

**stream System.IO.Stream required**

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<OfficeConversionReport>`

`public ExcelRange SetBaseline()` [#](#method-setbaseline)

[ExcelCell.cs:626](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L626)

Restores every cell in the range to the normal baseline.

Returns

`ExcelRange`

`public ExcelRange SetBold(bool bold = true)` [#](#method-setbold-boolean)

[ExcelCell.cs:585](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L585)

Sets or clears bold font style for every cell in the range.

Parameters

**bold bool = true optional**

Returns

`ExcelRange`

SetBorder 2 overloads

`public ExcelRange SetBorder(ExcelBorderStyle style, OfficeColor? color = null)` [#](#method-setborder-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor)

[ExcelCell.cs:539](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L539)

Applies a border style to every edge of every cell in the range.

Parameters

**style OfficeIMO.Excel.ExcelBorderStyle required**

**color OfficeIMO.OfficeColor? = null optional**

Returns

`ExcelRange`

`public ExcelRange SetBorder(ExcelCellBorders borders, ExcelBorderStyle style, OfficeColor? color = null)` [#](#method-setborder-officeimo-excel-excelcellborders-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor)

[ExcelCell.cs:545](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L545)

Sets selected border edges of every cell in the range while preserving other edges and styles.

Parameters

**borders OfficeIMO.Excel.ExcelCellBorders required**

**style OfficeIMO.Excel.ExcelBorderStyle required**

**color OfficeIMO.OfficeColor? = null optional**

Returns

`ExcelRange`

`public ExcelRange SetColor(OfficeColor color)` [#](#method-setcolor-officeimo-officecolor)

[ExcelCell.cs:559](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L559)

Applies a font color to every cell in the range.

Parameters

**color OfficeIMO.OfficeColor required**

Returns

`ExcelRange`

`public ExcelRange SetDiagonalBorder(ExcelBorderStyle style, OfficeColor? color = null, bool diagonalUp = true, bool diagonalDown = true)` [#](#method-setdiagonalborder-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor-boolean-boolean)

[ExcelCell.cs:551](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L551)

Applies diagonal borders to every cell in the range.

Parameters

**style OfficeIMO.Excel.ExcelBorderStyle required**

**color OfficeIMO.OfficeColor? = null optional**

**diagonalUp bool = true optional**

**diagonalDown bool = true optional**

Returns

`ExcelRange`

`public ExcelRange SetFillColor(OfficeColor color)` [#](#method-setfillcolor-officeimo-officecolor)

[ExcelCell.cs:515](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L515)

Applies a solid fill color to every cell in the range. Theme colors stay linked to the workbook theme.

Parameters

**color OfficeIMO.OfficeColor required**

Returns

`ExcelRange`

`public ExcelRange SetFontFamily(string fontFamily)` [#](#method-setfontfamily-string)

[ExcelCell.cs:567](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L567)

Applies a font family name to every cell in the range.

Parameters

**fontFamily string required**

Returns

`ExcelRange`

`public ExcelRange SetFontSize(OfficeLength fontSize)` [#](#method-setfontsize-officeimo-officelength)

[ExcelCell.cs:576](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L576)

Applies a positive physical font size to every cell in the range.

Parameters

**fontSize OfficeIMO.OfficeLength required**

Returns

`ExcelRange`

`public ExcelRange SetGradientFill(OfficeColor fromColor, OfficeColor toColor, double degree = 0)` [#](#method-setgradientfill-officeimo-officecolor-officeimo-officecolor-double)

[ExcelCell.cs:509](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L509)

Applies a two-color linear gradient fill to every cell in the range.

Parameters

**fromColor OfficeIMO.OfficeColor required**

**toColor OfficeIMO.OfficeColor required**

**degree double = 0 optional**

Returns

`ExcelRange`

`public ExcelRange SetHorizontalAlignment(ExcelHorizontalAlignment alignment)` [#](#method-sethorizontalalignment-officeimo-excel-excelhorizontalalignment)

[ExcelCell.cs:521](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L521)

Sets the horizontal alignment of every cell in the range.

Parameters

**alignment OfficeIMO.Excel.ExcelHorizontalAlignment required**

Returns

`ExcelRange`

`public ExcelRange SetItalic(bool italic = true)` [#](#method-setitalic-boolean)

[ExcelCell.cs:591](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L591)

Sets or clears italic font style for every cell in the range.

Parameters

**italic bool = true optional**

Returns

`ExcelRange`

`public ExcelRange SetNumberFormat(string numberFormat)` [#](#method-setnumberformat-string)

[ExcelCell.cs:500](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L500)

Applies a number format to every cell in the range.

Parameters

**numberFormat string required**

Returns

`ExcelRange`

`public ExcelRange SetShrinkToFit(bool shrinkToFit = true)` [#](#method-setshrinktofit-boolean)

[ExcelCell.cs:641](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L641)

Sets or clears shrink-to-fit text alignment for every cell in the range.

Parameters

**shrinkToFit bool = true optional**

Returns

`ExcelRange`

`public ExcelRange SetStrikethrough(bool strikethrough = true)` [#](#method-setstrikethrough-boolean)

[ExcelCell.cs:609](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L609)

Sets or clears strikethrough font style for every cell in the range.

Parameters

**strikethrough bool = true optional**

Returns

`ExcelRange`

`public ExcelRange SetSubscript()` [#](#method-setsubscript)

[ExcelCell.cs:623](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L623)

Formats every cell in the range as subscript.

Returns

`ExcelRange`

`public ExcelRange SetSuperscript()` [#](#method-setsuperscript)

[ExcelCell.cs:620](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L620)

Formats every cell in the range as superscript.

Returns

`ExcelRange`

`public ExcelRange SetTextRotation(int rotation)` [#](#method-settextrotation-int32)

[ExcelCell.cs:649](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L649)

Sets Excel text rotation for every cell in the range.

Parameters

**rotation int required**

Returns

`ExcelRange`

SetUnderline 2 overloads

`public ExcelRange SetUnderline(bool underline = true)` [#](#method-setunderline-boolean)

[ExcelCell.cs:597](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L597)

Sets or clears single underline font style for every cell in the range.

Parameters

**underline bool = true optional**

Returns

`ExcelRange`

`public ExcelRange SetUnderline(ExcelUnderlineStyle underlineStyle)` [#](#method-setunderline-officeimo-excel-excelunderlinestyle)

[ExcelCell.cs:603](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L603)

Sets the native Excel underline style for every cell in the range.

Parameters

**underlineStyle OfficeIMO.Excel.ExcelUnderlineStyle required**

Returns

`ExcelRange`

`public ExcelRange SetValues(object?[,] values)` [#](#method-setvalues-object-0-0)

[ExcelRange.Values.cs:6](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRange.Values.cs#L6)

Writes a rectangular matrix whose dimensions exactly match this range.

Parameters

**values object?[,] required**

Returns

`ExcelRange`

`public ExcelRange SetVerticalAlignment(ExcelVerticalAlignment alignment)` [#](#method-setverticalalignment-officeimo-excel-excelverticalalignment)

[ExcelCell.cs:527](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L527)

Sets the vertical alignment of every cell in the range.

Parameters

**alignment OfficeIMO.Excel.ExcelVerticalAlignment required**

Returns

`ExcelRange`

`public ExcelRange SetVerticalTextAlignment(ExcelVerticalTextAlignment alignment)` [#](#method-setverticaltextalignment-officeimo-excel-excelverticaltextalignment)

[ExcelCell.cs:615](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L615)

Sets the native Excel baseline, superscript, or subscript alignment for every cell in the range.

Parameters

**alignment OfficeIMO.Excel.ExcelVerticalTextAlignment required**

Returns

`ExcelRange`

`public ExcelRange SetWrapText(bool wrapText = true)` [#](#method-setwraptext-boolean)

[ExcelCell.cs:533](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L533)

Sets or clears text wrapping for every cell in the range.

Parameters

**wrapText bool = true optional**

Returns

`ExcelRange`

`public ExcelRange SortByColumn(int columnOffset, bool ascending = true, bool hasHeader = true)` [#](#method-sortbycolumn-int32-boolean-boolean)

[ExcelCell.cs:448](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L448)

Sorts the range by a 1-based column offset.

Parameters

**columnOffset int required**

**ascending bool = true optional**

**hasHeader bool = true optional**

Returns

`ExcelRange`

ToImage 3 overloads

`public OfficeImageExportResult ToImage(ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-toimage-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

[ExcelRange.Imaging.Conversion.cs:9](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/Imaging/ExcelRange.Imaging.Conversion.cs#L9)

Renders the range using the encoding in OfficeImageExportOptions.Format.

Parameters

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OfficeImageExportResult`

`public OfficeImageExportResult ToImage(ExcelImageExportOptions? options, out OfficeConversionReport report, CancellationToken cancellationToken = default)` [#](#method-toimage-officeimo-excel-excelimageexportoptions-officeimo-officeconversionreport-threading-cancellationtoken)

[ExcelRange.Imaging.Conversion.cs:14](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/Imaging/ExcelRange.Imaging.Conversion.cs#L14)

Renders the range and returns its immutable fidelity report.

Parameters

**options OfficeIMO.Excel.ExcelImageExportOptions? required**

**report OfficeIMO.OfficeConversionReport required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OfficeImageExportResult`

`public OfficeImageExportResult ToImage(OfficeImageExportFormat format, ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-toimage-officeimo-drawing-officeimageexportformat-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

[ExcelRange.Imaging.cs:19](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/Imaging/ExcelRange.Imaging.cs#L19)

Exports this range as a supported raster format or SVG.

Parameters

**format OfficeIMO.Drawing.OfficeImageExportFormat required**

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`OfficeImageExportResult`

`public async Task<OfficeImageExportResult> ToImageAsync(ExcelImageExportOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-toimageasync-officeimo-excel-excelimageexportoptions-threading-cancellationtoken)

Renders the range with cancellation and returns the encoded image and its diagnostics.

Parameters

**options OfficeIMO.Excel.ExcelImageExportOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Task<OfficeImageExportResult>`

`public ExcelRange TransformTextCase(OfficeTextCase textCase, CultureInfo? culture = null)` [#](#method-transformtextcase-officeimo-drawing-officetextcase-globalization-cultureinfo)

[ExcelCell.cs:633](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L633)

Changes stored text casing in text cells while preserving cell and rich-run formatting. Formulas and non-text values are left unchanged.

Parameters

**textCase OfficeIMO.Drawing.OfficeTextCase required**

**culture System.Globalization.CultureInfo? = null optional**

Returns

`ExcelRange`

`public ExcelMutationResult TransposeTo(string destinationTopLeft, ExcelMutationPlanOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-transposeto-string-officeimo-excel-excelmutationplanoptions-threading-cancellationtoken)

[ExcelCell.cs:470](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L470)

Copies this range to a destination with rows and columns transposed.

Parameters

**destinationTopLeft string required**

**options OfficeIMO.Excel.ExcelMutationPlanOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`ExcelMutationResult`

`public ExcelRange Unmerge()` [#](#method-unmerge)

[ExcelCell.cs:484](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L484)

Removes merge definitions that overlap the range.

Returns

`ExcelRange`

`public ExcelRangeDataValidationBuilder Validation()` [#](#method-validation)

[ExcelCell.cs:421](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L421)

Adds data validation rules to the range.

Returns

`ExcelRangeDataValidationBuilder`

## Inherited Methods

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

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

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

Inherited from object

Returns

`int`

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

Inherited from object

Returns

`Type`

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

Inherited from object

Returns

`string?`

## Properties

`public ExcelSheet Sheet { get; }` [#](#property-sheet)

[ExcelCell.cs:403](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L403)

Gets the worksheet that owns the range.

`public string Address { get; }` [#](#property-address)

[ExcelCell.cs:405](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L405)

Gets the A1 range address; areas are separated by spaces.

`public int FirstRow { get; }` [#](#property-firstrow)

[ExcelCell.cs:407](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L407)

Gets the first row in the range (of all areas).

`public int FirstColumn { get; }` [#](#property-firstcolumn)

[ExcelCell.cs:409](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L409)

Gets the first column in the range.

`public int LastRow { get; }` [#](#property-lastrow)

[ExcelCell.cs:411](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L411)

Gets the last row in the range.

`public int LastColumn { get; }` [#](#property-lastcolumn)

[ExcelCell.cs:413](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L413)

Gets the last column in the range.

`public ExcelCell FirstCell { get; }` [#](#property-firstcell)

[ExcelCell.cs:418](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelCell.cs#L418)

Gets a wrapper for the top-left cell.

<!-- PowerForge markdown artifact sha256:292FC79C5DC07ACAFB7E2277BC9A67EFE842C7ABF7F09BA06FB7029740A6E903 -->
