# ExcelCellScope

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

Class 

`OfficeIMO.Excel`

**Namespace**

`OfficeIMO.Excel`

**Assembly**

`OfficeIMO.Excel`

**Modifiers**

sealed

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

## Inheritance

- object
- ExcelCellScope

## Usage

Explore 27 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 25

- Method [ExcelCellScope.Baseline](/api/excel/officeimo-excel-excelcellscope/#method-baseline)
- Method [ExcelCellScope.Bold](/api/excel/officeimo-excel-excelcellscope/#method-bold-boolean)
- Method [ExcelCellScope.Border](/api/excel/officeimo-excel-excelcellscope/#method-border-officeimo-excel-excelcellborders-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor)
- Method [ExcelCellScope.Color](/api/excel/officeimo-excel-excelcellscope/#method-color-officeimo-officecolor)
- Method [ExcelCellScope.DiagonalBorder](/api/excel/officeimo-excel-excelcellscope/#method-diagonalborder-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor-boolean-boolean)
- Method [ExcelCellScope.Error](/api/excel/officeimo-excel-excelcellscope/#method-error-string)
- Method [ExcelCellScope.FillColor](/api/excel/officeimo-excel-excelcellscope/#method-fillcolor-officeimo-officecolor)
- Method [ExcelCellScope.FontFamily](/api/excel/officeimo-excel-excelcellscope/#method-fontfamily-string)
- Method [ExcelCellScope.FontSize](/api/excel/officeimo-excel-excelcellscope/#method-fontsize-officeimo-officelength)
- Method [ExcelCellScope.Formula](/api/excel/officeimo-excel-excelcellscope/#method-formula-string)
- Method [ExcelCellScope.GradientFill](/api/excel/officeimo-excel-excelcellscope/#method-gradientfill-officeimo-officecolor-officeimo-officecolor-double)
- Method [ExcelCellScope.HorizontalAlignment](/api/excel/officeimo-excel-excelcellscope/#method-horizontalalignment-officeimo-excel-excelhorizontalalignment)
- Method [ExcelCellScope.Italic](/api/excel/officeimo-excel-excelcellscope/#method-italic-boolean)
- Method [ExcelCellScope.NumberFormat](/api/excel/officeimo-excel-excelcellscope/#method-numberformat-string)
- Method [ExcelCellScope.RichText](/api/excel/officeimo-excel-excelcellscope/#method-richtext-officeimo-excel-excelrichtextrun)
- Method [ExcelCellScope.ShrinkToFit](/api/excel/officeimo-excel-excelcellscope/#method-shrinktofit-boolean)
- Method [ExcelCellScope.Strikethrough](/api/excel/officeimo-excel-excelcellscope/#method-strikethrough-boolean)
- Method [ExcelCellScope.Subscript](/api/excel/officeimo-excel-excelcellscope/#method-subscript)
- Method [ExcelCellScope.Superscript](/api/excel/officeimo-excel-excelcellscope/#method-superscript)
- Method [ExcelCellScope.TextRotation](/api/excel/officeimo-excel-excelcellscope/#method-textrotation-int32)
- Method [ExcelCellScope.Underline](/api/excel/officeimo-excel-excelcellscope/#method-underline-boolean)
- Method [ExcelCellScope.Value](/api/excel/officeimo-excel-excelcellscope/#method-value-dateonly)
- Method [ExcelCellScope.VerticalAlignment](/api/excel/officeimo-excel-excelcellscope/#method-verticalalignment-officeimo-excel-excelverticalalignment)
- Method [ExcelCellScope.VerticalTextAlignment](/api/excel/officeimo-excel-excelcellscope/#method-verticaltextalignment-officeimo-excel-excelverticaltextalignment)
- Method [ExcelCellScope.WrapText](/api/excel/officeimo-excel-excelcellscope/#method-wraptext-boolean)

### Accepted by parameters 2

- Method [ExcelRangeScope.Cell](/api/excel/officeimo-excel-excelrangescope/#method-cell-int32-int32-action-officeimo-excel-excelcellscope) parameter `configure`
- Method [ExcelSheetScope.Cell](/api/excel/officeimo-excel-excelsheetscope/#method-cell-int32-int32-action-officeimo-excel-excelcellscope) parameter `configure`

Filter members 

Show inherited

## Methods

`public ExcelCellScope Baseline()` [#](#method-baseline)

Restores the cell text to the normal baseline.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Bold(bool bold = true)` [#](#method-bold-boolean)

Sets or clears bold font style.

Parameters

**bold bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

Border 2 overloads

`public ExcelCellScope Border(ExcelBorderStyle style, OfficeColor? color = null)` [#](#method-border-officeimo-excel-excelborderstyle-nullable-officeimo-officecolor)

Applies a border style to the cell.

Parameters

**style OfficeIMO.Excel.ExcelBorderStyle required**

The value.

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

The value.

Returns

`ExcelCellScope` The same scope.

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

Sets selected border edges while preserving other edges and cell styles.

Parameters

**borders OfficeIMO.Excel.ExcelCellBorders required**

The value.

**style OfficeIMO.Excel.ExcelBorderStyle required**

The value.

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

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Color(OfficeColor color)` [#](#method-color-officeimo-officecolor)

Sets the font color using a hex color value.

Parameters

**color OfficeIMO.OfficeColor required**

The value.

Returns

`ExcelCellScope` The same scope.

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

Applies diagonal borders to the cell.

Parameters

**style OfficeIMO.Excel.ExcelBorderStyle required**

The value.

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

The value.

**diagonalUp bool = true optional**

The value.

**diagonalDown bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Error(string errorText)` [#](#method-error-string)

Writes a native Excel error value, such as #N/A or #DIV/0!.

Parameters

**errorText string required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope FillColor(OfficeColor color)` [#](#method-fillcolor-officeimo-officecolor)

Sets the solid fill color. Theme colors stay linked to the workbook theme.

Parameters

**color OfficeIMO.OfficeColor required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope FontFamily(string fontFamily)` [#](#method-fontfamily-string)

Sets the font family name.

Parameters

**fontFamily string required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope FontSize(OfficeLength fontSize)` [#](#method-fontsize-officeimo-officelength)

Sets a positive physical font size.

Parameters

**fontSize OfficeIMO.OfficeLength required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Formula(string formula)` [#](#method-formula-string)

Sets the cell formula while keeping any existing value as its cached result. This is not a redaction API: rebuild the workbook from approved data to remove sensitive historic content.

Parameters

**formula string required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope GradientFill(OfficeColor fromColor, OfficeColor toColor, double degree = 0)` [#](#method-gradientfill-officeimo-officecolor-officeimo-officecolor-double)

Sets a two-color linear gradient fill using literal or theme colors.

Parameters

**fromColor OfficeIMO.OfficeColor required**

The value.

**toColor OfficeIMO.OfficeColor required**

The value.

**degree double = 0 optional**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope HorizontalAlignment(ExcelHorizontalAlignment alignment)` [#](#method-horizontalalignment-officeimo-excel-excelhorizontalalignment)

Sets the horizontal alignment.

Parameters

**alignment OfficeIMO.Excel.ExcelHorizontalAlignment required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Italic(bool italic = true)` [#](#method-italic-boolean)

Sets or clears italic font style.

Parameters

**italic bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope NumberFormat(string numberFormat)` [#](#method-numberformat-string)

Applies a number format to the cell.

Parameters

**numberFormat string required**

The value.

Returns

`ExcelCellScope` The same scope.

RichText 2 overloads

`public ExcelCellScope RichText(params ExcelRichTextRun[] runs)` [#](#method-richtext-officeimo-excel-excelrichtextrun)

Replaces the cell contents with rich inline text runs.

Parameters

**runs OfficeIMO.Excel.ExcelRichTextRun[] required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope RichText(IEnumerable<ExcelRichTextRun> runs)` [#](#method-richtext-collections-generic-ienumerable-officeimo-excel-excelrichtextrun)

Replaces the cell contents with rich inline text runs.

Parameters

**runs System.Collections.Generic.IEnumerable<OfficeIMO.Excel.ExcelRichTextRun> required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope ShrinkToFit(bool shrinkToFit = true)` [#](#method-shrinktofit-boolean)

Sets or clears shrink-to-fit text alignment.

Parameters

**shrinkToFit bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Strikethrough(bool strikethrough = true)` [#](#method-strikethrough-boolean)

Sets or clears strikethrough font style.

Parameters

**strikethrough bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Subscript()` [#](#method-subscript)

Formats the cell text as subscript.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Superscript()` [#](#method-superscript)

Formats the cell text as superscript.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope TextRotation(int rotation)` [#](#method-textrotation-int32)

Sets Excel text rotation. Use 0-90 for upward rotation, 91-180 for downward rotation, or 255 for stacked vertical text.

Parameters

**rotation int required**

The value.

Returns

`ExcelCellScope` The same scope.

Underline 2 overloads

`public ExcelCellScope Underline(bool underline = true)` [#](#method-underline-boolean)

Sets or clears underline font style.

Parameters

**underline bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Underline(ExcelUnderlineStyle underlineStyle)` [#](#method-underline-officeimo-excel-excelunderlinestyle)

Sets the native Excel underline style.

Parameters

**underlineStyle OfficeIMO.Excel.ExcelUnderlineStyle required**

The value.

Returns

`ExcelCellScope` The same scope.

Value 19 overloads

`public ExcelCellScope Value(object? value)` [#](#method-value-object)

Sets the cell value, inferring the stored type. Dates and times get a date or duration number format unless the cell already has one.

Parameters

**value object? required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(string value)` [#](#method-value-string)

Sets Value.

Parameters

**value string required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(double value)` [#](#method-value-double)

Sets Value.

Parameters

**value double required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(float value)` [#](#method-value-single)

Sets Value.

Parameters

**value float required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(decimal value)` [#](#method-value-decimal)

Sets Value.

Parameters

**value decimal required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(int value)` [#](#method-value-int32)

Sets Value.

Parameters

**value int required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(long value)` [#](#method-value-int64)

Sets Value.

Parameters

**value long required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(short value)` [#](#method-value-int16)

Sets Value.

Parameters

**value short required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(uint value)` [#](#method-value-uint32)

Sets Value.

Parameters

**value uint required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(ulong value)` [#](#method-value-uint64)

Sets Value.

Parameters

**value ulong required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(ushort value)` [#](#method-value-uint16)

Sets Value.

Parameters

**value ushort required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(byte value)` [#](#method-value-byte)

Sets Value.

Parameters

**value byte required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(sbyte value)` [#](#method-value-sbyte)

Sets Value.

Parameters

**value sbyte required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(bool value = true)` [#](#method-value-boolean)

Sets Value.

Parameters

**value bool = true optional**

The value. True when omitted.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(DateTime value)` [#](#method-value-datetime)

Sets Value.

Parameters

**value System.DateTime required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(DateTimeOffset value)` [#](#method-value-datetimeoffset)

Sets Value.

Parameters

**value System.DateTimeOffset required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(TimeSpan value)` [#](#method-value-timespan)

Sets Value.

Parameters

**value System.TimeSpan required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(DateOnly value)` [#](#method-value-dateonly)

Sets Value.

Parameters

**value System.DateOnly required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope Value(TimeOnly value)` [#](#method-value-timeonly)

Sets Value.

Parameters

**value System.TimeOnly required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope VerticalAlignment(ExcelVerticalAlignment alignment)` [#](#method-verticalalignment-officeimo-excel-excelverticalalignment)

Sets the vertical alignment.

Parameters

**alignment OfficeIMO.Excel.ExcelVerticalAlignment required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope VerticalTextAlignment(ExcelVerticalTextAlignment alignment)` [#](#method-verticaltextalignment-officeimo-excel-excelverticaltextalignment)

Sets the native Excel baseline, superscript, or subscript alignment.

Parameters

**alignment OfficeIMO.Excel.ExcelVerticalTextAlignment required**

The value.

Returns

`ExcelCellScope` The same scope.

`public ExcelCellScope WrapText(bool wrapText = true)` [#](#method-wraptext-boolean)

Sets or clears text wrapping.

Parameters

**wrapText bool = true optional**

The value.

Returns

`ExcelCellScope` The same scope.

## Inherited Methods

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

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

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

Inherited from object

Returns

`int`

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

Inherited from object

Returns

`Type`

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

Inherited from object

Returns

`string?`

## Properties

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

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

<!-- PowerForge markdown artifact sha256:8CCCF1A31DD8C04A9E1CF5F44283819BAAB78C82EFFF21395FA2A0561DBCDF80 -->
