| Release 1.6.1 29 June 2005 |
Developer's reference |
![]() |
| Reference > N_XLS_FORMAT > of_set_num_format |
of_set_num_format() method
Define the numerical format of a number in Excel. It controls whether a number is displayed as an integer, a floating point number, a date, a currency value or some other user defined format
Syntax
| format.of_set_num_format ( format ) |
Parameters
| Format | A string or a blob (unicode string) whose value is the numerical format or an integer whose value is the index of built-in format |
Excel's built-in formats are shown in the following table:
| Index | Type | Format String |
| 0 | General | General |
| 1 | Decimal | 0 |
| 2 | Decimal | 0.00 |
| 3 | Decimal | #,##0 |
| 4 | Decimal | #,##0.00 |
| 5 | Currency | ($#,##0_);($#,##0) |
| 6 | Currency | ($#,##0_);[Red]($#,##0) |
| 7 | Currency | ($#,##0.00_);($#,##0.00) |
| 8 | Currency | ($#,##0.00_);[Red]($#,##0.00) |
| 9 | Percent | 0% |
| 10 | Percent | 0.00% |
| 11 | Scientific | 0.00E+00 |
| 12 | Fraction | # ?/? |
| 13 | Fraction | # ??/?? |
| 14 | Date | m/d/yy |
| 15 | Date | d-mmm-yy |
| 16 | Date | d-mmm |
| 17 | Date | mmm-yy |
| 18 | Time | h:mm AM/PM |
| 19 | Time | h:mm:ss AM/PM |
| 20 | Time | h:mm |
| 21 | Time | h:mm:ss |
| 22 | Date/Time | m/d/yy h:mm |
| .. | . . . . | . . . . . . . . . |
| 37 | Account | (#,##0_);(#,##0) |
| 38 | Account | (#,##0_);[Red](#,##0) |
| 39 | Account | (#,##0.00_);(#,##0.00) |
| 40 | Account | (#,##0.00_);[Red](#,##0.00) |
| 41 | Currency | _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) |
| 42 | Currency | _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_) |
| 43 | Currency | _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) |
| 44 | Currency | _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_) |
| 45 | Time | mm:ss |
| 46 | Time | [h]:mm:ss |
| 47 | Time | mm:ss.0 |
| 48 | Scientific | ##0.0E+0 |
| 49 | Text | @ |
Return value
Integer. Returns 1 if it succeeds and -1 if an error occurs. If argument value is NULL, of_create returns NULL.
Description
Default format is General.
You should ensure that the format string is valid in Excel prior to using it in WriteExcel.
Examples
format1.of_set_num_format ( 'd mmm yyyy' ) // Format string format2.of_set_num_format ( 15 ) //built-in format format3.of_set_num_format ( '0.000' ) format4.of_set_num_format ( '#,##0' ) format5.of_set_num_format ( '#,##0.00' ) format6.of_set_num_format ( '$0.00' ) format7.of_set_num_format ( 'mm/dd/yy' )
| © 2003-2005 Desta, Ltd. All rights reserved. | SupportDesk |