CellValue.FromDateTime(DateTime, Boolean) Method
Converts the DateTime object to a cell value using the specified date system.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
value | Date |
A Date |
use1904Date |
Boolean | true, if the 1904 date system is used; otherwise, false. |
#Returns
Type | Description |
---|---|
Cell |
A Cell |
#Remarks
Dates are stored in cells as numbers called serial values. A serial value is an integer that is the number of elapsed days from the first day in the date system. SpreadsheetControl supports the 1900 and 1904 date systems for serial values. For details, refer to Dates and Times in Cells.
The CellValue.NumericValue property of the cell value object returns the number contained in a cell (a serial value), and the CellValue.DateTimeValue property returns the corresponding date in the date system used in the workbook (the Workbook.DocumentSettings.Calculation.Use1904DateSystem property).
Use the FromDateTime method to get the CellValue object from the DateTime object. The date’s serial value is calculated based on the passed use1904DateSystem parameter value.
For example, consider the date 12/17/2012. The table below demonstrates which serial values this date is represented by in each date system, how the date can be assigned to a cell in each date system, and how the date displayed depends on the date system applied in the workbook.
Date System to Input Date | Serial Value of 12/17/2012 | Input Date | Use1904Date | Use1904Date |
---|---|---|---|---|
1900 | 41260 | cell. cell. | Cell Cell | Cell Cell |
1904 | 39798 | cell. | Cell Cell | Cell Cell |