NativeExcel2 for .Net Developer's Reference

IRange.NumberFormat Property

Gets or sets the format code for the specified range.

[Visual Basic]
PropertyNumberFormatAsString
[C#]
stringNumberFormat{get;set;}
[C++]
__propertyString*get_NumberFormat();
__propertyvoidset_NumberFormat(String*);
[JScript]
functiongetNumberFormat():String
functionsetNumberFormat(String);

Example

These examples set the number format for cell A10, row one, and column C (respectively) on sheet one.

[C#]
 IRange range = book.Worksheets[1].Range;
 range["A10"].NumberFormat = "#,##0.00";
 range.Rows[1].NumberFormat = "hh:mm:ss";
 range.Columns[3].NumberFormat = "$#,##0.00;[Red]($#,##0.00)"; 
[VisualBasic]
 Dim range As IRange = book.Worksheets(1).Range
 range("A10").NumberFormat = "#,##0.00"
 range.Rows(1).NumberFormat = "hh:mm:ss"
 range.Columns(3).NumberFormat = "$#,##0.00;[Red]($#,##0.00)"
[C++]
 IRange* range = book->Worksheets->Item[1]->Range;
 range->Item[S"A10"]->NumberFormat = S"#,##0.00";
 range->Rows->Item[1]->NumberFormat = S"hh:mm:ss";
 range->Columns->Item[3]->NumberFormat = S"$#,##0.00;[Red]($#,##0.00)"; 

See Also

IRange Interface | NativeExcel Namespace | DisplayValue Property