Syncfusion.XlsIO.Base
Example 


Value2 Property (IRange)

Gets or sets the cell value.
Syntax
'Declaration
 
Property Value2 As Object
'Usage
 
Dim instance As IRange
Dim value As Object
 
instance.Value2 = value
 
value = instance.Value2
object Value2 {get; set;}
Remarks

Sets different data types values as a object. Value2 first checks whether the specified object has the type known for it (DateTime, TimeSpan, Double, Int). If yes, then it uses the corresponding typed properties (DateTime, TimeSpan, and Number). Otherwise, it calls Value property with String data type.

The only difference between the Value2 property and the Value property is that the Value2 property does not use the Currency and Date data types. Also, it does not support FormulaArray value.

Example
The following code illustrates how to set and access Value2 property of the Range.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
            
IWorksheet sheet = workbook.Worksheets[0];
            
//Assigning Value2 property of the Range
sheet["A1"].Value2 = DateTime.Now;
sheet["A2"].Value2 = 45;
sheet["A3"].Value2 = false;
            
// Checking Range types.
bool isDateTime =  sheet["A1"].HasDateTime;
bool isNumber =  sheet["A2"].HasNumber;
bool isboolean = sheet["A3"].HasBoolean;
            
workbook.SaveAs("Value2.xlsx");
workbook.Close();
excelEngine.Dispose();
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also