style() applies text, paragraph, and cell formatting properties to a selection of rows and columns in one call. It bundles what the individual convenience functions do separately, using officer formatting objects.
Use style() when you need to change multiple property types (text, paragraph, cell) on the same selection in one operation. Use the individual functions (bold(), color(), align(), etc.) when you only need to change a single property.
Function signature
Parameters
A
flextable object.Row selector. Accepts integer indices, a one-sided formula (e.g.,
~ col > 5), or a logical vector. NULL selects all rows in the specified part.Column selector. Accepts integer indices, column names, a formula, or a logical vector.
NULL selects all columns.An
officer::fp_text() or officer::fp_text_lite() object defining text-level formatting: font family, font size, color, bold, italic, underline, and related properties. Equivalent to combining bold(), italic(), color(), fontsize(), font(), and highlight().An
officer::fp_par() or officer::fp_par_lite() object defining paragraph-level formatting: text alignment, padding, line spacing, and tab stops. Equivalent to combining align(), padding(), and line_spacing().An
officer::fp_cell() object defining cell-level formatting: background color, borders, and vertical alignment. Equivalent to combining bg(), border(), and valign().Which part of the table to target:
"body", "header", "footer", or "all".Return value
The modifiedflextable object.
Examples
Apply cell and paragraph formatting to the whole table, then apply text formatting to a row/column subset:Property types reference
| Argument | officer object | Equivalent convenience functions |
|---|---|---|
pr_t | fp_text(), fp_text_lite() | bold(), italic(), color(), fontsize(), font(), highlight() |
pr_p | fp_par(), fp_par_lite() | align(), padding(), line_spacing() |
pr_c | fp_cell() | bg(), border(), valign() |
See also
bold(),italic(),color()— individual text formatting shortcutsfontsize(),font(),highlight()— more text shortcutsset_flextable_defaults()— change initial formatting for all new tables