Page tree
Skip to end of metadata
Go to start of metadata

Description

A Cell object represents a single cell in a worksheet. To return a Cell object use Worksheet.Cells. Specify the cell by 0-based row and column indexes or by Excel-style reference:

C#
vb.net

Examples

C#
vb.net

Properties

Name

Description

ColumnNumber

Returns the cell's 0-based column number.

Comment

Returns a Comment object representing a note attached to the cell, separate from other cell content. If a comment is not associated with the specified cell, a new comment will be created and returned.

ConditionalFormat

Returns the ConditionalFormat object associated with the current Cell. If a ConditionalFormat object does not exist, a new one will be created. Any changes made to the object returned will only affect this Cell.

DataValidation

Returns the cell's DataValidation object if one exists. Otherwise, returns 'null'.

Formula

Sets or returns a cell formula. If no formula is associated with the cell, the property returns an empty string.

HasComment

Returns true if a Comment object is associated with the cell.

HasConditionalFormat

Returns whether or not the Cell contains a ConditionalFormat object.

HasDataValidation

Returns true if the cell has a DataValidation object associated with it.

IsMerged

Returns whether or not the Cell is a merged cell.

Name

Returns the cell's Excel-style name (such as, "B5").

RowNumber

Returns the cell's 0-based row number.

Style

Sets or returns a Style object that determines how the cell looks, including number format, font, orientation, etc. Accessing the cell's style through Cell.Style will not affect the formatting of other cells with the same global style.

Value

Sets or returns a cell value.  Empty cells will return either null or empty string.

ValueType

Returns the data type of the cell's value: "Blank, "Boolean", "Date", "Error", "Numeric", or "Text".

Methods

Name

Description

ApplyStyle(Style)

Applies a style to the cell. When a style is applied - rather than set (see Cell.Style ) - only the differences between the new style and style properties previously assigned to the cell (through the ExcelWriter API) will take effect. For example, if the cell has a background color and the new style applied does not contain a background color, the cell's color will not be affected. However, if the new style includes a background color, it will replace the existing background color of the cell.

ClearContent()

Clears a cell's content. Calling this method is equivalent to setting a cell's value to null.

ClearRichTextFormatting()

Clears all rich text formatting within the cell. The font of the text will be set to that set in Cell.Style.Font.

CreateAnchor(Int32, Int32)

Creates an anchor within the specified cell. An anchor represents the position of a floating (non-cell data) object within a spreadsheet.

CreateHyperlink(String)

Creates a new hyperlink in the cell pointing to the specified href. This hyperlink is automatically added to the worksheet. The cell value will be converted to hyperlinks.

GetCharacters(Int32)

Returns a CharacterRun object representing a range of characters within the cell. Use this property to set the font on specified characters within the cell.

GetCharacters(Int32, Int32)

Returns a CharacterRun object representing a range of characters within the cell. Use this method to set the font on specified characters within the cell.

RemoveComment()

Removes the comment associated with the cell. A comment is a note attached to the cell, separate from other cell content. To find out if a comment is attached to the cell, use Cell.HasComment .

RemoveConditionalFormat()

Removes any ConditionalFormat objects from the current Cell.

RemoveDataValidation()

Removes the DataValidation object associated with the cell.

SetConditionalFormat(ConditionalFormat)

Applies the specified ConditionalFormat to the current
Cell. If the cell already has a ConditionalFormat, it will be replaced by the specified
ConditionalFormat.

ToString()

Returns a string representation of the Cell object.

Unmerge()

Unmerges the current cell. A merged cell is referenced using the location of the leftmost, topmost constituent cell.

Nested Classes

Name

Description

CellValueType

A CellValueType value specifies the data type of the cell's value.
  • No labels