Difference between revisions of "Documentation/How Tos/Calc: STYLE function"
From Apache OpenOffice Wiki
< Documentation | How Tos
(Initial content) |
m |
||
(12 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | __NOTOC__ | + | {{DISPLAYTITLE:STYLE function}} |
+ | {{Documentation/CalcFunc SpreadsheetTOC | ||
+ | |ShowPrevNext=block | ||
+ | |PrevPage=Documentation/How_Tos/Calc:_HYPERLINK_function | ||
+ | |NextPage=Documentation/How_Tos/Calc:_Statistical_functions | ||
+ | }}__NOTOC__ | ||
== STYLE == | == STYLE == | ||
− | Applies a style (for example a | + | Applies a style (for example, a color) to a cell. |
=== Syntax: === | === Syntax: === | ||
Line 17: | Line 22: | ||
: <tt>'''STYLE'''</tt> returns the numeric value <tt>'''0'''</tt>, so it may be added on to an existing calculation in the cell without changing the result. See the examples below. | : <tt>'''STYLE'''</tt> returns the numeric value <tt>'''0'''</tt>, so it may be added on to an existing calculation in the cell without changing the result. See the examples below. | ||
+ | : Another way to apply styles can be found at {{menu|Format|Conditional Formating…}}. | ||
+ | |||
+ | : There is no direct way to determine (in a formula) what formatting has been applied to a cell. | ||
=== Example: === | === Example: === | ||
In these examples, it is assumed you have created a new style "Red" where the cell has a red background. "Default" is the default style already defined in Calc. | In these examples, it is assumed you have created a new style "Red" where the cell has a red background. "Default" is the default style already defined in Calc. | ||
+ | |||
<tt>'''=3 + 5 + STYLE("Red"; 3; "Default")'''</tt> | <tt>'''=3 + 5 + STYLE("Red"; 3; "Default")'''</tt> | ||
Line 34: | Line 43: | ||
<tt>'''="Some text" & T(STYLE("Red"))'''</tt> | <tt>'''="Some text" & T(STYLE("Red"))'''</tt> | ||
− | : displays the text <tt>'''Some text'''</tt> with a red background. The <tt>'''STYLE'''</tt> function always returns <tt>'''0'''</tt>, so <tt>'''T(0)'''</tt> | + | : displays the text <tt>'''Some text'''</tt> with a red background. The <tt>'''STYLE'''</tt> function always returns <tt>'''0'''</tt>, so <tt>'''T(0)'''</tt> will return a zero length string which can be concatenated to an existing string without affecting it. |
− | = | + | <tt>'''=IF(STYLE("Red"); ""; <i>yourformula</i>)'''</tt> |
− | ''' | + | : where <tt>'''<i>yourformula</i>'''</tt> stands for some formula, displays the result of <tt>'''<i>yourformula</i>'''</tt> with a red background. This method might be useful if you cannot predict whether <tt>'''<i>yourformula</i>'''</tt> will return text or a number (for example, with <tt>'''HLOOKUP'''</tt>). |
=== Issues: === | === Issues: === | ||
The STYLE function is unique to Calc. | The STYLE function is unique to Calc. | ||
+ | |||
+ | {{SeeAlso|EN| | ||
+ | * [[Documentation/How_Tos/Calc: SQRT function|SQRT]] | ||
+ | * [[Documentation/How_Tos/Calc: CURRENT function|CURRENT]] | ||
+ | * [[Documentation/How_Tos/Calc: T function|T]] | ||
+ | |||
+ | * [[Documentation/How_Tos/Calc: Spreadsheet functions|Spreadsheet functions]] | ||
+ | |||
+ | * [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]] | ||
+ | * [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}} | ||
+ | [[Category: Documentation/Reference/Calc/Spreadsheet functions]] |