% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/as_flextable_rtables.R
\name{as_flextable.TableTree}
\alias{as_flextable.TableTree}
\alias{as_flextable.ElementaryTable}
\title{Transform an rtables object into a flextable}
\usage{
\method{as_flextable}{TableTree}(x, indent_padding = 4, ...)

\method{as_flextable}{ElementaryTable}(x, indent_padding = 4, ...)
}
\arguments{
\item{x}{a \code{TableTree} or \code{ElementaryTable} object produced
by the 'rtables' package.}

\item{indent_padding}{base left padding in points per indentation
level. Default is \code{4}.}

\item{...}{unused arguments}
}
\value{
a flextable object.
}
\description{
produce a flextable from a \code{TableTree} or
\code{ElementaryTable} object produced with the
'rtables' package.

The conversion uses \code{\link[formatters:matrix_form]{formatters::matrix_form()}} to extract the
formatted content, column spans, alignments, indentation
and footnotes, then maps them to flextable features.

Indentation of row labels is rendered with left padding.

Label rows (\code{LabelRow}) are displayed in bold in the first column.
Content rows (\code{ContentRow}) are displayed entirely in bold.

When \code{LabelRow} groups exist, \code{\link[=paginate]{paginate()}} is applied so
that all rows belonging to the same group are kept together
on the same page in Word and RTF output.

To paginate the resulting flextable into multiple pages, use
\code{\link[=split_to_pages]{split_to_pages()}}, \code{\link[=split_rows]{split_rows()}}, or \code{\link[=split_columns]{split_columns()}} after
calling \code{as_flextable()}.
}
\examples{
if (require("rtables", character.only = TRUE, quietly = TRUE)) {
  library(rtables)

  lyt <- basic_table(title = "Demographic Summary") \%>\%
    split_cols_by("ARM") \%>\%
    split_rows_by("SEX") \%>\%
    analyze("AGE", afun = mean, format = "xx.x")

  tbl <- build_table(lyt, DM)
  as_flextable(tbl)
}
}
\seealso{
\code{\link[=split_to_pages]{split_to_pages()}}, \code{\link[=split_rows]{split_rows()}}, \code{\link[=split_columns]{split_columns()}}
}
