Name

format — Returns a formatted string using the specified format string and arguments.

Syntax

format(format, args...)
              

The FORMAT function has the following arguments:

format

A string containing a format specification.

args...

Zero or more arguments that provide values that will be substituted in to the format string.

Description

Returns a new string that is formatted according to the format string specified in the first argument, supplemented by additional optional arguments. This function is implement using the Java String format method. Check the Java API documentation for details about the format string.

Examples

Formula

Description

Result

format('Hello')

Return a format string that has no arguments

'Hello'

format('Hello %1$', 'World')

Return a format string with one argument

'Hello World'

format('a=%1$f', 13.6)

Format a floating point number with default width

'a=13.600000'

format('a=%1$4.2f', 13.6)

Format a floating point number with specified width

'a=13.60'

format('a=%1$4.2e', 13.6)

Format a floating point number in a scientific format with specified width

'a=1.36e+01'

format('a=%1$4.2f (%1$4.2e)', 13.6)

Format a floating point number several ways

'a=13.60 (1.36e+01)'

format('wow_%1$d_wow', 12)

Format a decimal number surrounded by text

'wow_12_wow'

format('wow_%1$4d_wow', 12)

Format a decimal number with a width surrounded by text

'wow_ 12_wow'

format('wow_%1$04d_wow', 12)

Format a decimal number with leading zeros surrounded by text

'wow_0012_wow'

format('%1$s_%2$04d_wow', 'Pine', 12)

Format a string and a number number with leading zeros

'Pine_0012'