aspnet-16165-components-spreadsheet-cell-basics-cell-data-types.md
A cell value is stored in the CellValue object and can be accessed by the Cell.Value property. You can specify a value in two ways:
cell.Value = 10;cell.Formula = "= SUM(3,7)";The Spreadsheet determines the type of the inserted/calculated data and sets the cell’s Type property value. Use the appropriate Value property to get the cell value.
The available cell value types are listed below.
|
|
Identify the Type
|
Value
|
Sample Input
|
| | --- | --- | --- | --- | --- | |
None
|
|
|
cell.Value = null;
|
| |
Numeric
|
|
|
cell.Value = 12345678;
cell.NumberFormat = "#,#";
|
12,345,678
| |
|
|
|
cell.Value = new DateTime(2012, 12, 10);
cell.NumberFormat = "m/d/yy";
|
12/10/12
| |
Text
|
|
|
cell.Value = "Sample Text";
|
Sample Text
| |
Boolean
|
|
|
cell.Value = true;
|
TRUE
| |
|
|
|
cell.Formula = "=5/0";
|
#DIV/0!
|
Note
ASPxSpreadsheet does not support embedded images.
You can format Numeric and DateTime cell values. For instance, a number can appear in a cell as a percentage, decimal, currency, accounting, date or time value.
Assign a format pattern to the Cell.NumberFormat property to format a value in a cell. For more information, please review the following topic: How to: Specify Number or Date Format for Cell Content.
Use the Cell.DisplayText property to get the formatted value as it is displayed in a cell.
worksheet.Cells["A1"].Formula = "= Now()";
worksheet.Cells["A1"].NumberFormat = "m/d/yy h:mm";
// worksheet.Cells["A1"].DisplayText returns "5/20/2020 13:08"
worksheet.Cells["B1"].Value = 1.6;
worksheet.Cells["B1"].NumberFormat = "0.0%";
// worksheet.Cells["B1"].DisplayText returns "160.0%"