All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

CellRange.Value Property

Gets or sets a cell value.

Namespace: DevExpress.Spreadsheet

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

Declaration

CellValue Value { get; set; }
Property Value As CellValue
CellValue Value { get; set; }
Property Value As CellValue
CellValue Value { get; set; }
Property Value As CellValue

Property Value

Type Description
CellValue

A cell value.

Property Value

Type Description
CellValue

A cell value.

Property Value

Type Description
CellValue

A cell value.

Remarks

A CellValue object specifies a value contained in a cell. Use the Value property to specify or obtain a cell value.

You can set the Value property to an object of the String, DateTime, Boolean or numeric type (Int32, Double, etc.). See the Cell Data Types topic for details on cell values and their types.

Note

You cannot assign a Decimal value to a cell via the CellRange.Value property. Use the CellRange.SetValue or CellValue.FromObject method instead.

The CellRange.SetValue method allows you to assign an object of any type to a cell value. It uses the default converter to convert the specified object to a CellValue and assigns it to a cell. To use a custom converter, use the CellValue.FromObject method. See the How to: Convert Objects to Cell Values and Cell Values to Objects example.

You can also use a formula to calculate a cell value dynamically.

If a cell has no data, the Value property returns an empty value object (CellValue.IsEmpty is true).

Examples

This example demonstrates how to use the CellRange.Value property to add data of different types to worksheet cells.

Enclose your code in the Workbook.BeginUpdate - Workbook.EndUpdate method calls to improve performance when you edit multiple cells in a document.

// Add data of different types to cells.
worksheet.Cells["B1"].Value = DateTime.Now;
worksheet.Cells["B2"].Value = Math.PI;
worksheet.Cells["B3"].Value = "Have a nice day!";
worksheet.Cells["B4"].Value = CellValue.ErrorReference;
worksheet.Cells["B5"].Value = true;
worksheet.Cells["B6"].Value = float.MaxValue;
worksheet.Cells["B7"].Value = 'a';
worksheet.Cells["B8"].Value = Int32.MaxValue;

// Fill all cells in the range with 10.
worksheet.Range["B10:E10"].Value = 10;
See Also