Quick reference
| Function | What it does |
|---|---|
border_remove(x) | Remove all borders |
border_outer(x, border, part) | Set the outer (perimeter) border |
border_inner(x, border, part) | Set all inner borders (horizontal + vertical) |
border_inner_h(x, border, part) | Set inner horizontal borders |
border_inner_v(x, border, part) | Set inner vertical borders |
hline(x, i, j, border, part) | Set bottom border of selected rows |
hline_top(x, j, border, part) | Set top border of a table part |
hline_bottom(x, j, border, part) | Set bottom border of a table part |
vline(x, i, j, border, part) | Set right border of selected columns |
vline_left(x, i, border, part) | Set left outer border |
vline_right(x, i, border, part) | Set right outer border |
surround(x, i, j, border, ...) | Surround specific cells with borders |
fp_border_default(...) | Create a default border properties object |
Border properties
All border functions accept aborder argument that must be created with officer::fp_border() or the convenience wrapper fp_border_default().
fp_border_default() parameters:
Border color as a color name or hex string.
Border width in points.
Border line style. Common values:
"solid", "dashed", "dotted".border_remove()
Removes all borders from a flextable.
A
flextable object.border_outer()
Applies a border to the outer (perimeter) cells of one or all parts.
A
flextable object.Border properties from
officer::fp_border(). If NULL, uses the global default border color.Which part to target:
"body", "header", "footer", or "all".border_inner(), border_inner_h(), border_inner_v()
Apply borders to the inner cells of the table.
border_inner()— sets both horizontal and vertical inner borders.border_inner_h()— sets only inner horizontal borders (between rows).border_inner_v()— sets only inner vertical borders (between columns).
A
flextable object.Border properties from
officer::fp_border(). If NULL, uses the global default.Which part to target:
"body", "header", "footer", or "all".hline(), hline_top(), hline_bottom()
Draw horizontal lines at specific rows.
hline()— draws a line below each selected rowi. Sets both the bottom border of rowiand the top border of rowi + 1for consistent rendering. Wheni = NULL, applies to every row.hline_top()— draws a line at the very top of a part (the outer top edge). Does not accept a row selector.hline_bottom()— draws a line at the very bottom of a part (the outer bottom edge). Does not accept a row selector.
A
flextable object.Row selector (
hline only). NULL targets all rows.Column selector.
NULL targets all columns.Border properties from
officer::fp_border(). If NULL, uses the global default.Which part to target:
"body", "header", "footer", or "all".vline(), vline_left(), vline_right()
Draw vertical lines at specific columns.
vline()— draws a line to the right of each selected columnj. Also sets the left border of columnj + 1. Whenj = NULL, applies to every column.vline_left()— draws a line on the left outer edge of the table. Always targets column 1.vline_right()— draws a line on the right outer edge of the table. Always targets the last column.
A
flextable object.Row selector.
NULL targets all rows.Column selector (
vline only). NULL targets all columns.Border properties from
officer::fp_border(). If NULL, uses the global default.Which part to target:
"body", "header", "footer", or "all".surround()
Draws borders around a specific set of cells.
A
flextable object.Row selector.
Column selector.
Shortcut to set all four edges at once.
Top border. Overrides
border if set.Bottom border. Overrides
border if set.Left border. Overrides
border if set.Right border. Overrides
border if set.Which part to target:
"body", "header", or "footer".Examples
Basic outer/inner border composition:surround():
See also
fix_border_issues()— fix border rendering inconsistenciesbefore()— helper to select rows before a summary row