Developer's reference PB2XLS for PowerBuilder

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

FormatA 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:

IndexTypeFormat String
0GeneralGeneral
1Decimal0
2Decimal0.00
3Decimal#,##0
4Decimal#,##0.00
5Currency($#,##0_);($#,##0)
6Currency($#,##0_);[Red]($#,##0)
7Currency($#,##0.00_);($#,##0.00)
8Currency($#,##0.00_);[Red]($#,##0.00)
9Percent0%
10Percent0.00%
11Scientific0.00E+00
12Fraction# ?/?
13Fraction# ??/??
14Datem/d/yy
15Dated-mmm-yy
16Dated-mmm
17Datemmm-yy
18Timeh:mm AM/PM
19Timeh:mm:ss AM/PM
20Timeh:mm
21Timeh:mm:ss
22Date/Timem/d/yy h:mm
... . . .. . . . . . . . .
37Account(#,##0_);(#,##0)
38Account(#,##0_);[Red](#,##0)
39Account(#,##0.00_);(#,##0.00)
40Account(#,##0.00_);[Red](#,##0.00)
41Currency_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)
42Currency_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)
43Currency_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
44Currency_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)
45Timemm:ss
46Time[h]:mm:ss
47Timemm:ss.0
48Scientific##0.0E+0
49Text@

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' )