Documentation/Calc Functions/STYLE

From The Document Foundation Wiki
Jump to: navigation, search


Im-jabber.svg

Under construction.
For now, see the system Help files.


Function name:

STYLE

Category:

Spreadsheet

Summary:

Applies a style to the cell containing the formula. After a set amount of time, another style can be applied. This function always returns the value 0, allowing you to add it to another function without changing the value. Together with the CURRENT function you can apply a color to a cell depending on the value. For example: =...+STYLE(IF(CURRENT()>3;"red";"green")) applies the style "red" to the cell if the value is greater than 3, otherwise the style "green" is applied. Both cell formats, "red" and "green" have to be defined beforehand.

Syntax:

STYLE("Style"; Time; "Style2")

Returns:

Arguments:

Style is the name of a cell style assigned to the cell. Style names must be entered in quotation marks.

Time is an optional time range in seconds. If this parameter is missing the style will not be changed after a certain amount of time has passed.

Style2 is the optional name of a cell style assigned to the cell after a certain amount of time has passed. If this parameter is missing "Default" is assumed.

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

Additional details:

Examples:

=STYLE("Invisible";60;"Default") formats the cell in transparent format for 60 seconds after the document was recalculated or loaded, then the Default format is assigned. Both cell formats have to be defined beforehand.

Since STYLE() has a numeric return value of zero, this return value gets appended to a string. This can be avoided using T() as in the following example:

="Text"&T(STYLE("myStyle"))

See also CURRENT() for another example.

Related LibreOffice functions:

ODF standard:

Equivalent Excel functions: