• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class Cell

Represents a single cell in a worksheet.

Inheritance
object
AbstractFormattable
Cell
Implements
IEnumerable<object>
IEnumerable
Inherited Members
AbstractFormattable.Alignment
AbstractFormattable.Fill
AbstractFormattable.Font
AbstractFormattable.Format
AbstractFormattable.IsLocked
AbstractFormattable.IsFormulaHidden
AbstractFormattable.QuotePrefix
AbstractFormattable.Borders
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: DRIT.Spreadsheet
Assembly: DRIT.Spreadsheet.dll
Syntax
public class Cell : AbstractFormattable, IEnumerable<object>, IEnumerable
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Examples
// Access and modify a cell
var cell = worksheet.Cells["A1"];
cell.Value = 42;
cell.Formula = "=SUM(B1:B10)";
cell.Format = Formats.Currency;

Fields

Merged

Indicates whether this cell is merged.

Declaration
public bool Merged
Field Value
Type Description
bool
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Properties

AbsoluteLabel

Gets the absolute address label of the cell.

Declaration
public string AbsoluteLabel { get; }
Property Value
Type Description
string
Remarks

For example: $A$1

Address

Gets the address of this cell.

Declaration
public CellAddress Address { get; }
Property Value
Type Description
CellAddress
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

ArrayFormulaRange

Gets the range of the array formula. Returns null if the the formula is not an array formula

Declaration
public Range ArrayFormulaRange { get; }
Property Value
Type Description
Range
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

BooleanValue

Gets the cell value as a bool, or null when the value is not boolean.

Declaration
public bool? BooleanValue { get; }
Property Value
Type Description
bool?
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Column

Get the column which contains the current cell.

Declaration
public Column Column { get; }
Property Value
Type Description
Column
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

ColumnCount

Gets the number of columns in the array (always 1 for a single cell).

Declaration
public int ColumnCount { get; }
Property Value
Type Description
int
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Comment

Specifies the comment of the cell. The getter creates a comment for an untouched cell and returns null after the annotation has been explicitly cleared.

Declaration
public Comment Comment { get; set; }
Property Value
Type Description
Comment
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

DateValue

Specifies the DateTime value of the cell.

Declaration
public DateTime? DateValue { get; set; }
Property Value
Type Description
DateTime?
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

DisplayBorders

Get the displayed borders of the cell.

Declaration
public AbstractBorders DisplayBorders { get; }
Property Value
Type Description
AbstractBorders
Remarks

If the cell has conditional formatting applied with border formatting and the cell value fulfills the critera it returns t

DisplayFill

Get the displayed background fill of the cell

Declaration
public CellFill DisplayFill { get; }
Property Value
Type Description
CellFill
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

DisplayFont

Get the displayed font weight of the cell.

Declaration
public AbstractFont DisplayFont { get; }
Property Value
Type Description
AbstractFont
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

DisplayHorizontalAlignment

Gets the Horizontal Alignment of the cell as it is displayed.

Declaration
public HorizontalCellAlignment DisplayHorizontalAlignment { get; }
Property Value
Type Description
HorizontalCellAlignment
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

DoubleValue

Gets the cell value as a double, or null when the value is not numeric.

Declaration
public double? DoubleValue { get; }
Property Value
Type Description
double?
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

FormattedValue

Gets the string representation of the cell as formatted and displayed.

Declaration
public string FormattedValue { get; }
Property Value
Type Description
string
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Formula

Get or set the formula of the cell. Changing the cell may also change the value.

Declaration
public string Formula { get; set; }
Property Value
Type Description
string
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

HasContent

Gets a value indicating whether the cell has content.

Declaration
public bool HasContent { get; }
Property Value
Type Description
bool
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Hyperlink

Specifies the hyperlink of the current cell. The getter creates a hyperlink for an untouched cell and returns null after the annotation has been explicitly cleared.

Declaration
public Hyperlink Hyperlink { get; set; }
Property Value
Type Description
Hyperlink
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

InlineRichText

Gets the rich value

Declaration
public RichTextParagraph InlineRichText { get; set; }
Property Value
Type Description
RichTextParagraph
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

IntValue

Gets the integer value of the cell.

Declaration
public int IntValue { get; }
Property Value
Type Description
int
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

this[int, int]

Gets the cell at the specified row and column offset.

Declaration
public object this[int row, int column] { get; }
Parameters
Type Name Description
int row

The row offset.

int column

The column offset.

Property Value
Type Description
object

The cell at the specified position.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Label

Gets the address label of the cell.

Declaration
public string Label { get; }
Property Value
Type Description
string
Remarks

For example: A1

LocalizedFormula

Set or get the formula in the current locale.

Declaration
public string LocalizedFormula { get; set; }
Property Value
Type Description
string
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Phonetics

Specifies the phonetic text for the cell.

Declaration
public PhoneticText Phonetics { get; set; }
Property Value
Type Description
PhoneticText
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

R1C1Formula

Specifies the formula for this cell in R1C1 notation. On set, the R1C1 formula is converted to A1 notation relative to this cell's position. On get, the stored A1 formula is converted to R1C1 notation relative to this cell's position.

Declaration
public string R1C1Formula { get; set; }
Property Value
Type Description
string
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

RichText

Gets the rich value

Declaration
public RichTextParagraph RichText { get; set; }
Property Value
Type Description
RichTextParagraph
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Row

Get the row which contains the current cell.

Declaration
public Row Row { get; }
Property Value
Type Description
Row
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

RowCount

Gets the number of rows in the array (always 1 for a single cell).

Declaration
public int RowCount { get; }
Property Value
Type Description
int
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

StringValue

Gets the cell value as a string, or null when the cell is empty.

Declaration
public string StringValue { get; }
Property Value
Type Description
string
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

StringValueType

Gets the string value type of the cell.

Declaration
public StringValueType StringValueType { get; }
Property Value
Type Description
StringValueType
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Style

Get or get the style of the row or column

Declaration
public override CellStyle Style { get; set; }
Property Value
Type Description
CellStyle
Overrides
AbstractFormattable.Style
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Tag

Specifies an arbitrary object value that can be used to store custom information about this cell.

Declaration
public object Tag { get; set; }
Property Value
Type Description
object
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

TimeSpanValue

Specifies the TimeSpan value of the cell.

Declaration
public TimeSpan? TimeSpanValue { get; set; }
Property Value
Type Description
TimeSpan?
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Value

Get or set the value of the cell.

Declaration
public object Value { get; set; }
Property Value
Type Description
object
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Exceptions
Type Condition
ArgumentException

ValueType

Gets the value type of the cell.

Declaration
public ValueType ValueType { get; }
Property Value
Type Description
ValueType
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Worksheet

Get the sheet which contains the current cell.

Declaration
public override Worksheet Worksheet { get; }
Property Value
Type Description
Worksheet
Overrides
AbstractFormattable.Worksheet
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Methods

AddComment(string, RichTextParagraph)

Adds the supplied comment to the Cell.

Declaration
public void AddComment(string author, RichTextParagraph richText)
Parameters
Type Name Description
string author

The author used by the operation.

RichTextParagraph richText

The rich text used by the operation.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

AddComment(string, string)

Adds a comment to the cell.

Declaration
public void AddComment(string author, string text)
Parameters
Type Name Description
string author

The author of the comment.

string text

The text content of the comment.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

AddConditionalFormatting(ConditionalFormatting)

Adds conditional formatting to the cell.

Declaration
public void AddConditionalFormatting(ConditionalFormatting conditionalFormatting)
Parameters
Type Name Description
ConditionalFormatting conditionalFormatting

The conditional formatting to add.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

ApplyStyle(CellStyleTemplate)

Applies a CellStyleTemplate to this cell. Only properties explicitly set on the template are applied; null properties leave existing formatting unchanged.

Declaration
public void ApplyStyle(CellStyleTemplate template)
Parameters
Type Name Description
CellStyleTemplate template

The style template to apply.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetBoolean()

Gets the Boolean value of the cell.

Declaration
public bool GetBoolean()
Returns
Type Description
bool
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetComplex()

Gets the complex number value of the cell.

Declaration
public Complex GetComplex()
Returns
Type Description
Complex

The complex value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetDateTime()

Gets the DateTime value of the cell.

Declaration
public DateTime GetDateTime()
Returns
Type Description
DateTime

The DateTime value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetDouble()

Gets the double value of the cell.

Declaration
public double GetDouble()
Returns
Type Description
double

The double value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetEnumerator()

Returns an enumerator that iterates through the cell's value.

Declaration
public IEnumerator<object> GetEnumerator()
Returns
Type Description
IEnumerator<object>

An enumerator for the cell's value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetHtmlString(bool)

Returns the HTML representation of the cell's value and formatting.

Declaration
public string GetHtmlString(bool html5)
Parameters
Type Name Description
bool html5

If true, produces HTML5-style output (span with inline style). If false, produces HTML4-style output (Font tags).

Returns
Type Description
string
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetInt32()

Gets the Int32 value of the cell.

Declaration
public double GetInt32()
Returns
Type Description
double

The Int32 value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetString()

Gets the string value of the cell.

Declaration
public string GetString()
Returns
Type Description
string

The string value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

GetValue<T>()

Gets the cell value converted to the specified type. Supports double, int, string, bool, and DateTime. For DateTime, OA-date conversion is handled automatically.

Declaration
public T GetValue<T>()
Returns
Type Description
T

The converted value, or default(T) if the cell is empty.

Type Parameters
Name Description
T

The target type.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Select()

Set the ActiveCell and Selection to this cell.

Declaration
public void Select()
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

SetArrayFormula(string, int, int)

Sets an array formula on this cell, spanning a block of rowCount rows and columnCount columns starting at this cell.

Declaration
public void SetArrayFormula(string formula, int rowCount, int columnCount)
Parameters
Type Name Description
string formula
int rowCount
int columnCount
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

SetComment(string, string)

Sets a comment on the cell with the specified text and author. This overload takes text first, then author, matching the parameter order used by both competitors.

Declaration
public void SetComment(string text, string author)
Parameters
Type Name Description
string text

The text content of the comment.

string author

The author of the comment.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

SetValue(bool)

Sets the value of the cell to a boolean.

Declaration
public void SetValue(bool value)
Parameters
Type Name Description
bool value

The boolean value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

SetValue(DateTime)

Sets the value of the cell to a DateTime.

Declaration
public void SetValue(DateTime value)
Parameters
Type Name Description
DateTime value

The DateTime value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

SetValue(double)

Sets the value of the cell to a double.

Declaration
public void SetValue(double value)
Parameters
Type Name Description
double value

The double value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

SetValue(string)

Sets the value of the cell to a string.

Declaration
public void SetValue(string value)
Parameters
Type Name Description
string value

The string value.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

ToString()

Returns a string that represents the current object.

Declaration
public override string ToString()
Returns
Type Description
string

A string that represents the current object.

Overrides
object.ToString()
Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Operators

operator +(Cell, CellRelativeAddress)

Adds an offset to a cell to get another cell.

Declaration
public static Cell operator +(Cell cell, CellRelativeAddress offset)
Parameters
Type Name Description
Cell cell

The source cell.

CellRelativeAddress offset

The relative address offset.

Returns
Type Description
Cell

The cell at the offset position.

Remarks

A Cell is the fundamental unit of data storage in a worksheet. Each cell can contain a value, formula, comment, and formatting information.

Cells are accessed through the DRIT.Spreadsheet.Worksheet.Cells indexer or via Range objects.

Implements

IEnumerable<T>
IEnumerable
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX