Back to Devexpress

Cell Interface

officefileapi-devexpress-dot-spreadsheet-7d6c85aa.md

latest13.6 KB
Original Source

Cell Interface

A single cell in a worksheet.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface Cell :
    CellRange,
    Formatting,
    IEnumerable<Cell>,
    IEnumerable
vb
Public Interface Cell
    Inherits CellRange,
             Formatting,
             IEnumerable(Of Cell),
             IEnumerable

The following members return Cell objects:

Show 19 links

LibraryRelated API Members
WinForms ControlsCustomDrawCellEventArgsBase.Cell
CustomDrawCommentIndicatorEventArgs.Cell
SpreadsheetControl.ActiveCell
SpreadsheetControl.GetCellFromPoint(PointF)
WPF ControlsCellData.Cell
SpreadsheetControl.ActiveCell
SpreadsheetControl.GetCellFromPoint(PointF)
Office File APICellCollection.Item[String]
CellRange.Item[Int32, Int32]
CellRange.Item[Int32]
CellValueConversionErrorEventArgs.Cell
Column.Item[Int32]
Column.Item[String]
FloatingObject.BottomRightCell
FloatingObject.TopLeftCell
Row.Item[Int32]
Row.Item[String]
SpreadsheetCellEventArgsBase.Cell
Worksheet.Item[Int32, Int32]

Remarks

Cells are constituent elements of a worksheet. An individual cell is represented by the object that implements the Cell interface. This interface is inherited from the CellRange interface, which provides basic functionality to work with worksheet cells, cell ranges, rows and columns.

Worksheet data is stored in cells. Each cell holds a single piece of data - the cell value. To access a cell value, use the CellRange.Value property. The Cell.DisplayText property returns a string that specifies a formatted value as it is displayed in a cell.

A cell can also contain a formula that calculates the cell value dynamically. To specify a cell formula, use the CellRange.Formula property. In formulas, you can refer to cells and cell ranges using cell references of different types.

You can format cells to improve worksheet appearance. For more information, see the Formatting Cells and Conditional Formatting examples.

When working with worksheet data, you can access and modify individual cells, as well as cell range, entire rows and columns. For more information, see the Cells and Cell Ranges document that provides an overview of the functionality available to manage worksheet cells, and the Cells section that provides examples.

Example

This example demonstrates several ways to access individual cells.

  • By row and column indexes of a cell via the Worksheet.Item property.

  • By a cell reference (for example, A1, B2, etc.) or by row and column indexes from the worksheet’s collection of cells. Use the CellCollection.Item property.

  • By a column index or column heading from the specified row. Use the Row.Item property.

  • By a cell index from the specified range of cells, or by row and column offsets relative to the cell range. Use the CellRange.Item property. See the How to: Access a Range of Cells document to learn how to access an individual range of cells in a worksheet.

  • C#

  • VB.NET

csharp
using DevExpress.Spreadsheet;
// ...

IWorkbook workbook = spreadsheetControl1.Document;
Worksheet worksheet = workbook.Worksheets[0];

Cell cellA1 = worksheet[0, 0]; // Cell A1

Cell cellB2 = worksheet.Cells["B2"]; // Cell B2
Cell cellC2 = worksheet.Cells[1, 2]; // Cell C2

Cell cellD3 = worksheet.Cells[2, 3]; // Cell D3
Cell cellE4 = worksheet.Rows[3]["E"]; // Cell E4
Cell cellF4 = worksheet.Rows["4"][5]; // Cell F4

Cell cellG5 = worksheet.Columns[6][4]; // Cell G5
Cell cellH6 = worksheet.Columns["H"][5]; // Cell H6
Cell cellI7 = worksheet.Columns["I"]["7"]; // Cell I7

// Access a cell from the range of cells.
Cell cellB5 = worksheet.Range["B3:D6"][6]; // Cell B5
Cell cellD6 = worksheet.Range["B3:D6"][3, 2]; // Cell D6
vb
Imports DevExpress.Spreadsheet
' ...

Dim workbook As IWorkbook = spreadsheetControl1.Document
Dim worksheet As Worksheet = workbook.Worksheets(0)

Dim cellA1 As Cell = worksheet(0, 0) ' Cell A1

Dim cellB2 As Cell = worksheet.Cells("B2") ' Cell B2
Dim cellC2 As Cell = worksheet.Cells(1, 2) ' Cell C2

Dim cellD3 As Cell = worksheet.Cells(2, 3) ' Cell D3
Dim cellE4 As Cell = worksheet.Rows(3)("E") ' Cell E4
Dim cellF4 As Cell = worksheet.Rows("4")(5) ' Cell F4

Dim cellG5 As Cell = worksheet.Columns(6)(4) ' Cell G5
Dim cellH6 As Cell = worksheet.Columns("H")(5) ' Cell H6
Dim cellI7 As Cell = worksheet.Columns("I")("7") ' Cell I7

' Access a cell from the range of cells.
Dim cellB5 As Cell = worksheet.Range("B3:D6")(6) ' Cell B5
Dim cellD6 As Cell = worksheet.Range("B3:D6")(3, 2) ' Cell D6

Extension Methods

Show 35 items

ExportToImage()

ExportToImage(RangeImageOptions)

ExportToImage(String, ImageFileFormat)

ExportToImage(String, ImageFileFormat, RangeImageOptions)

ExportToImage(Stream, ImageFileFormat)

ExportToImage(Stream, ImageFileFormat, RangeImageOptions)

Clear()

ClearContents()

ClearFormats()

ClearHyperlinks()

ClearComments()

GroupRows(Boolean)

GroupColumns(Boolean)

UnGroupColumns(Boolean)

UnGroupRows(Boolean)

ClearOutline(Boolean, Boolean)

Subtotal(Int32, List<Int32>, Int32, String)

RemoveSubtotal()

Merge()

Merge(MergeCellsMode)

UnMerge()

Insert()

Delete()

Insert(InsertCellsMode)

Delete(DeleteMode)

Select()

Select(Boolean)

AutoFitColumns()

AutoFitRows()

Sum(Boolean, Boolean)

Count(Boolean, Boolean)

NumericalCount(Boolean, Boolean)

Average(Boolean, Boolean)

Max(Boolean, Boolean)

Min(Boolean, Boolean)

See Also

Cell Members

Cells and Cell Ranges

WinForms Spreadsheet Control Examples

DevExpress.Spreadsheet Namespace