Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/davidgohel/flextable/llms.txt

Use this file to discover all available pages before exploring further.

Use width() to set column widths and height() / height_all() to set row heights. Heights only take effect when hrule() is set to "atleast" or "exact".

width()

Sets the width of one or more columns.
width(x, j = NULL, width, unit = "in")
width() has no effect when set_table_properties(layout = "autofit") is active. In HTML output, column widths are not applied.
x
flextable
required
A flextable object.
j
integer | character
Column selector. NULL applies the width to all columns.
width
number
required
Column width. When j selects multiple columns, you can supply a single value (applied to all) or a vector of the same length as the number of selected columns.
unit
string
default:"\"in\""
Unit for the width value. One of "in" (inches), "cm", or "mm".

Example

ft <- flextable(head(iris))
ft <- width(ft, width = 1.5)
ft

height()

Sets the height of selected rows.
height(x, i = NULL, height, part = "body", unit = "in")
height() has no effect when hrule() is set to "auto" (the default), except in PowerPoint, which does not support automatic row height.
x
flextable
required
A flextable object.
i
integer | formula | logical
Row selector. NULL applies the height to all rows in the specified part.
height
number
required
Row height. Accepts a single value applied to all selected rows, or a vector of the same length as the number of selected rows.
part
string
default:"\"body\""
Which part to target: "body", "header", or "footer". "all" is not accepted.
unit
string
default:"\"in\""
Unit for the height value. One of "in" (inches), "cm", or "mm".

Example

ft <- flextable(head(iris))
ft <- height(ft, height = .5)
ft <- hrule(ft, rule = "exact")
ft

height_all()

Sets the same height for every row in a selected part. A convenience wrapper around height().
height_all(x, height, part = "all", unit = "in")
x
flextable
required
A flextable object.
height
number
required
A single positive numeric value to apply to all rows.
part
string
default:"\"all\""
Which part to target: "body", "header", "footer", or "all".
unit
string
default:"\"in\""
Unit for the height value. One of "in" (inches), "cm", or "mm".

Example

ft <- flextable(head(iris))
ft <- height_all(ft, height = 1)
ft <- hrule(ft, rule = "exact")
ft

See also

Build docs developers (and LLMs) love