
Convert a TableTree or a listing_df object to a flextable
Source:R/docx_exporter_functions.R
tt_to_flextable_j.RdThis function is based on rtables.officer::tt_to_flextable().
Usage
tt_to_flextable_j(
tt,
tblid = NULL,
theme = theme_docx_default_j(font = "Times New Roman", font_size = 9L, bold = NULL),
border = flextable::fp_border_default(width = 0.875, color = "black"),
titles_as_header = TRUE,
bold_titles = TRUE,
integrate_footers = TRUE,
counts_in_newline = FALSE,
paginate = tlg_type(tt) == "Table",
fontspec = formatters::font_spec("Times", 9L, 1.2),
colwidths = NULL,
label_width_ins = 2,
total_page_width = pg_width_by_orient(orientation == "landscape"),
orientation = "portrait",
nosplitin = list(row = character(), col = character()),
string_map = default_str_map,
markup_df_docx = dps_markup_df_docx,
reduce_first_col_indentation = FALSE,
tlgtype = tlg_type(tt),
col_gap = ifelse(tlgtype == "Listing", 0.5, 3),
round_type = formatters::obj_round_type(tt),
alignments = list(),
border_mat = make_header_bordmat(obj = tt),
validate = TRUE,
...
)Arguments
- tt
(
TableTreeorlisting_df)
the object to convert to flextable.- tblid
(
character)
output ID to be displayed in the title and last line of footer. When exporting, it will also be used as the output filename.
If NULL, a temp file will be created, its dirname will replace argumentoutput_dir, and its basename will replace argumenttblid.
(optional) Default = NULL.- theme
(function factory)
the theme to apply to the flextable.
(optional) Default =theme_docx_default_j().
Seetheme_docx_default_j()orrtables.officer::theme_docx_default()for more details.- border
(
fp_border)
border to use.
Default =flextable::fp_border_default(width = 0.875, color = "black").- titles_as_header
(
logical)
(optional) Default = TRUE.- bold_titles
(
logical)
(optional) Default = TRUE.(
logical)
(optional) Default = TRUE.- counts_in_newline
(
logical)
(optional) Default = FALSE.- paginate
(
logical)
(optional) Default = TRUE for TableTree and FALSE otherwise.- fontspec
(
font_spec)
font specification object.- colwidths
(
numeric)
column widths for the table.
(optional) Default = NULL.- label_width_ins
(
numeric)
label width in inches.
(optional) Default = 2.- total_page_width
(
numeric)
no need to be specified by end user.
(optional) Default = 6.38 ("portrait") or 8.88 ("landscape").- orientation
(
character)
one of: "portrait", "landscape".
(optional) Default = "portrait".- nosplitin
(
list)
path elements whose children should not be paginated within if it can be avoided. The list should have the format list(row=, col=).
E.g., list(col="TRT01A") means don't split within treatment arms unless all the associated columns don't fit on a single page.
(optional) Default = list(row = character(), col = character()).- string_map
(
tibble)
(optional) Default = default_str_map.- markup_df_docx
(
tibble)
(optional) Default = dps_markup_df_docx.- reduce_first_col_indentation
(
logical)
whether to reduce by 1 the indentation if we have vertical pagination. No need to be specified by the end user.
(optional) Default = FALSE.- tlgtype
(
character)
(optional) No need to be specified by end user.- col_gap
(
numeric)
(optional) Default = 3 (Tables) or 0.5 (Listings).- round_type
(
"iec"or"sas")
the type of rounding to perform. iec, the default, performs rounding compliant with IEC 60559, while sas performs nearest-value rounding consistent with rounding within SAS. See[formatters::format_value()]for more details.- alignments
(
list)
list of named lists. Vectorized. Used to specify individual column or cell alignments. Each named list containsrow,col, andvalue.
(optional) Default =list().- border_mat
(
matrix)
am x kmatrix where m is the number of columns of the input Table/Listing and k is the number of lines the header takes up.
See tidytlg::add_bottom_borders for what the matrix should contain. Users should only specify this when the default behavior does not meet their needs.- validate
(
logical(1))
Whether to validate the table structure usingrtables::validate_table_struct(). Defaults toTRUE. IfFALSE, a message will be displayed when validation fails.- ...
other parameters.
Note
The following features are not implemented in flextable,
and as a result they will only be visible when exporting to docx using
export_TLG_as_docx():
watermark
hanging indents
caption style
page numbering