The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

CellValue Class

A data value contained in a cell.

Namespace: DevExpress.Spreadsheet

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

Declaration

public class CellValue
Public Class CellValue
public class CellValue
Public Class CellValue

Remarks

Each cell in a worksheet has a value that is specified by the CellValue object. To access this object, use the Range.Value property. A cell value can be constant, or it can be calculated dynamically (if the cell contains a formula). If a cell does not contain any data, the cell value is empty (the CellValue.IsEmpty property is set to true).

A cell value can be of one of the following types: text, numeric, boolean or error. Dates and times are stored in cells as numbers. To display a cell numeric value as a date and time, apply the required number format to a cell via the Formatting.NumberFormat property. For detailed information, see the Dates and Times in Cells document.

To obtain the type of data contained in a cell, use the CellValue.Type property. To get an object of the corresponding type from the cell value object, use the CellValue.TextValue, CellValue.NumericValue, CellValue.DateTimeValue, CellValue.BooleanValue or CellValue.ErrorValue property, or the CellValue.ToObject method.

To set a cell value, you can directly assign the Range.Value property to an object of the String, DateTime, Boolean or any numeric type (e.g., Int32, Double, etc.). You can also use an object of any type to specify a cell value by calling the Range.SetValue method. It converts the passed object to the CellValue object using the default converter and assigns it to the cell. To use a custom converter instead of the default, use the CellValue.FromObject method. See the How to: Convert Objects to Cell Values and Cell Values to Objects example.

For more information on cell values and their types, see the Cell Data Types topic.

Examples

This example demonstrates how to use the Range.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;

Inheritance

Object
CellValue
See Also