ExcelCell
OfficeIMO.Excel
A worksheet cell handle: the sheet plus a 1-based row and column. It stores no cell state, so creating one in a loop allocates nothing; every member reads or writes the worksheet directly.
Inheritance
- ValueType
- ExcelCell
Usage
Explore 36 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 31
- Method ExcelCell.Clear
- Method ExcelCell.SetBaseline
- Method ExcelCell.SetBold
- Method ExcelCell.SetBorder
- Method ExcelCell.SetColor
- Method ExcelCell.SetDiagonalBorder
- Method ExcelCell.SetError
- Method ExcelCell.SetFillColor
- Method ExcelCell.SetFontFamily
- Method ExcelCell.SetFontSize
- Method ExcelCell.SetFormula
- Method ExcelCell.SetGradientFill
- Method ExcelCell.SetHorizontalAlignment
- Method ExcelCell.SetItalic
- Method ExcelCell.SetNumberFormat
- Method ExcelCell.SetRichText
- Method ExcelCell.SetShrinkToFit
- Method ExcelCell.SetStrikethrough
- Method ExcelCell.SetSubscript
- Method ExcelCell.SetSuperscript
- Method ExcelCell.SetTextRotation
- Method ExcelCell.SetUnderline
- Method ExcelCell.SetValue
- Method ExcelCell.SetValue``1
- Method ExcelCell.SetVerticalAlignment
- Method ExcelCell.SetVerticalTextAlignment
- Method ExcelCell.SetWrapText
- Method ExcelCell.TransformTextCase
- Method ExcelRange.Cell
- Property ExcelRange.FirstCell
- Method ExcelSheet.Cell
Accepted by parameters 5
- Method ExcelCell.Equals
- Method ExcelCell.op_Equality
- Method ExcelCell.op_Equality
- Method ExcelCell.op_Inequality
- Method ExcelCell.op_Inequality
Methods
public ExcelCell Clear(ExcelClearOptions options = All) #Clears selected cell data and metadata.
Parameters
- options OfficeIMO.Excel.ExcelClearOptions = All
Returns
ExcelCellpublic bool Equals(ExcelCell other) #Returns whether both handles address the same cell of the same worksheet object.
Parameters
- other OfficeIMO.Excel.ExcelCell
Returns
boolpublic override bool Equals(object? obj) #Indicates whether this instance and a specified object are equal.
Parameters
- obj object?
- The object to compare with the current instance.
Returns
bool true if obj and this instance are the same type and represent the same value; otherwise, false.public string GetFormattedText(IFormatProvider? provider = null) #Gets formatted display text for the cell value.
Parameters
- provider System.IFormatProvider? = null
Returns
stringpublic override int GetHashCode() #Returns the hash code for this instance.
Returns
int A 32-bit signed integer that is the hash code for this instance.public IReadOnlyList<ExcelRichTextRun> GetRichText() #Gets rich inline text runs from the cell.
Returns
IReadOnlyList<ExcelRichTextRun>public ExcelCellStyleInfo GetStyle() #Gets a read-only snapshot of the cell's visual style.
Returns
ExcelCellStyleInfopublic T? GetValue<T>() #Gets the cell value converted to the requested type.
Type Parameters
- T
Returns
T?public static bool op_Equality(ExcelCell left, ExcelCell right) #Returns whether both handles address the same cell.
Parameters
- left OfficeIMO.Excel.ExcelCell
- right OfficeIMO.Excel.ExcelCell
Returns
boolpublic static bool op_Inequality(ExcelCell left, ExcelCell right) #Returns whether the handles address different cells.
Parameters
- left OfficeIMO.Excel.ExcelCell
- right OfficeIMO.Excel.ExcelCell
Returns
boolpublic ExcelCell SetBold(bool bold = true) #Sets or clears bold font style.
Parameters
- bold bool = true
Returns
ExcelCellpublic ExcelCell SetBorder(ExcelBorderStyle style, OfficeColor? color = null) #Applies a border style to the cell.
Parameters
- style OfficeIMO.Excel.ExcelBorderStyle
- color OfficeIMO.OfficeColor? = null
Returns
ExcelCellpublic ExcelCell SetBorder(ExcelCellBorders borders, ExcelBorderStyle style, OfficeColor? color = null) #Sets selected border edges while preserving other edges and cell styles.
Parameters
- borders OfficeIMO.Excel.ExcelCellBorders
- style OfficeIMO.Excel.ExcelBorderStyle
- color OfficeIMO.OfficeColor? = null
Returns
ExcelCellpublic ExcelCell SetColor(OfficeColor color) #Sets the font color using a hex color value.
Parameters
- color OfficeIMO.OfficeColor
Returns
ExcelCellpublic ExcelCell SetDiagonalBorder(ExcelBorderStyle style, OfficeColor? color = null, bool diagonalUp = true, bool diagonalDown = true) #Applies diagonal borders to the cell.
Parameters
- style OfficeIMO.Excel.ExcelBorderStyle
- color OfficeIMO.OfficeColor? = null
- diagonalUp bool = true
- diagonalDown bool = true
Returns
ExcelCellpublic ExcelCell SetError(string errorText) #Writes a native Excel error value, such as #N/A or #DIV/0!.
Parameters
- errorText string
Returns
ExcelCellpublic ExcelCell SetFillColor(OfficeColor color) #Sets the solid fill color. Theme colors stay linked to the workbook theme.
Parameters
- color OfficeIMO.OfficeColor
Returns
ExcelCellpublic ExcelCell SetFontFamily(string fontFamily) #Sets the font family name.
Parameters
- fontFamily string
Returns
ExcelCellpublic ExcelCell SetFontSize(OfficeLength fontSize) #Sets a positive physical font size.
Parameters
- fontSize OfficeIMO.OfficeLength
Returns
ExcelCellpublic ExcelCell SetFormula(string formula) #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
Returns
ExcelCellpublic ExcelCell SetGradientFill(OfficeColor fromColor, OfficeColor toColor, double degree = 0) #Sets a two-color linear gradient fill using literal or theme colors.
Parameters
- fromColor OfficeIMO.OfficeColor
- toColor OfficeIMO.OfficeColor
- degree double = 0
Returns
ExcelCellpublic ExcelCell SetHorizontalAlignment(ExcelHorizontalAlignment alignment) #Sets the horizontal alignment.
Parameters
- alignment OfficeIMO.Excel.ExcelHorizontalAlignment
Returns
ExcelCellpublic ExcelCell SetItalic(bool italic = true) #Sets or clears italic font style.
Parameters
- italic bool = true
Returns
ExcelCellpublic ExcelCell SetNumberFormat(string numberFormat) #Applies a number format to the cell.
Parameters
- numberFormat string
Returns
ExcelCellpublic ExcelCell SetRichText(params ExcelRichTextRun[] runs) #Replaces the cell contents with rich inline text runs.
Parameters
- runs OfficeIMO.Excel.ExcelRichTextRun[]
Returns
ExcelCellpublic ExcelCell SetShrinkToFit(bool shrinkToFit = true) #Sets or clears shrink-to-fit text alignment.
Parameters
- shrinkToFit bool = true
Returns
ExcelCellpublic ExcelCell SetStrikethrough(bool strikethrough = true) #Sets or clears strikethrough font style.
Parameters
- strikethrough bool = true
Returns
ExcelCellpublic ExcelCell SetTextRotation(int rotation) #Sets Excel text rotation. Use 0-90 for upward rotation, 91-180 for downward rotation, or 255 for stacked vertical text.
Parameters
- rotation int
Returns
ExcelCellpublic ExcelCell SetUnderline(bool underline = true) #Sets or clears underline font style.
Parameters
- underline bool = true
Returns
ExcelCellpublic ExcelCell SetValue(object? value) #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?
Returns
ExcelCellpublic ExcelCell SetValue(string value) #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 string
Returns
ExcelCellpublic ExcelCell SetValue(double value) #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 double
Returns
ExcelCellpublic ExcelCell SetValue(float value) #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 float
Returns
ExcelCellpublic ExcelCell SetValue(decimal value) #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 decimal
Returns
ExcelCellpublic ExcelCell SetValue(int value) #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 int
Returns
ExcelCellpublic ExcelCell SetValue(long value) #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 long
Returns
ExcelCellpublic ExcelCell SetValue(short value) #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 short
Returns
ExcelCellpublic ExcelCell SetValue(uint value) #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 uint
Returns
ExcelCellpublic ExcelCell SetValue(ulong value) #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 ulong
Returns
ExcelCellpublic ExcelCell SetValue(ushort value) #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 ushort
Returns
ExcelCellpublic ExcelCell SetValue(byte value) #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 byte
Returns
ExcelCellpublic ExcelCell SetValue(sbyte value) #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 sbyte
Returns
ExcelCellpublic ExcelCell SetValue(bool value) #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 bool
Returns
ExcelCellpublic ExcelCell SetValue(DateTime value) #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 System.DateTime
Returns
ExcelCellpublic ExcelCell SetValue(DateTimeOffset value) #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 System.DateTimeOffset
Returns
ExcelCellpublic ExcelCell SetValue(TimeSpan value) #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 System.TimeSpan
Returns
ExcelCellpublic ExcelCell SetValue(DateOnly value) #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 System.DateOnly
Returns
ExcelCellpublic ExcelCell SetValue<T>(T? value) #Sets the cell value from a nullable value; null writes an empty value.
Type Parameters
- T
Parameters
- value T?
Returns
ExcelCellpublic ExcelCell SetVerticalAlignment(ExcelVerticalAlignment alignment) #Sets the vertical alignment.
Parameters
- alignment OfficeIMO.Excel.ExcelVerticalAlignment
Returns
ExcelCellpublic ExcelCell SetVerticalTextAlignment(ExcelVerticalTextAlignment alignment) #Sets the native Excel baseline, superscript, or subscript alignment.
Parameters
- alignment OfficeIMO.Excel.ExcelVerticalTextAlignment
Returns
ExcelCellpublic ExcelCell SetWrapText(bool wrapText = true) #Sets or clears text wrapping.
Parameters
- wrapText bool = true
Returns
ExcelCellpublic ExcelCell TransformTextCase(OfficeTextCase textCase, CultureInfo? culture = null) #Changes stored text casing while preserving cell or rich-run formatting. Formulas and non-text values are left unchanged.
Parameters
- textCase OfficeIMO.Drawing.OfficeTextCase
- culture System.Globalization.CultureInfo? = null
Returns
ExcelCellpublic bool TryGetValue<T>(out T? value) #Tries to get the cell value converted to the requested type.
Type Parameters
- T
Parameters
- value T?
Returns
boolInherited Methods
Properties
public ExcelSheet Sheet { get; } #Gets the worksheet that owns the cell.
Exceptions
InvalidOperationException– The handle is default and has no worksheet.