NativeExcel2 for .Net Developer's Reference

IRange.DisplayValue Property

Returns a formatted String representation of Value using NumberFormat

[Visual Basic]
PropertyReadOnlyDisplayValueAsObject
[C#]
objectDisplayValue{get;}
[C++]
__propertyObject*get_DisplayValue();
[JScript]
functiongetDisplayValue():Object

Property Value

If the range is a one- or two-dimensional range, the DisplayValue returns a string array of the same dimensions.

Example

This example demonstrates how to use DisplayValue property with the range of cells.

[C#]
 IRange r = book.Worksheets[1].Range; 

 r["A1"].Value = 10;
 r["A2"].Value = new DateTime(2005, 12, 3);
 r["A2"].NumberFormat = "DD.MM.YYYY";
 r["B1"].Value = "test string";
 r["B2"].Value = -200.44;

 string[,] arr;
 arr = (string[,])r["A1:B2"].DisplayValue;
 // arr[0,0] = "10"
 // arr[1,0] = "03.12.2005"
 // arr[0,1] = "test string"
 // arr[1,1] = "-200.44" 

See Also

IRange Interface | NativeExcel Namespace | Value Property | NumberFormat Property | Formula Property