1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/body_add_flextable.R
\name{body_add_flextable}
\alias{body_add_flextable}
\alias{body_replace_flextable_at_bkm}
\title{add flextable into a Word document}
\usage{
body_add_flextable(
x,
value,
align = NULL,
pos = "after",
split = NULL,
topcaption = TRUE,
keepnext = NULL
)
body_replace_flextable_at_bkm(
x,
bookmark,
value,
align = "center",
split = FALSE
)
}
\arguments{
\item{x}{an rdocx object}
\item{value}{\code{flextable} object}
\item{align}{left, center (default) or right.}
\item{pos}{where to add the flextable relative to the cursor,
one of "after", "before", "on" (end of line).}
\item{split}{set to TRUE if you want to activate Word
option 'Allow row to break across pages'.}
\item{topcaption}{if TRUE caption is added before the table, if FALSE,
caption is added after the table.}
\item{keepnext}{default to FALSE, 'keep with next' binds the table
to the first line of the next block (a paragraph or a table). It
ensures no page break happens between the two blocks.}
\item{bookmark}{bookmark id}
}
\description{
add a flextable into a Word document.
}
\section{body_replace_flextable_at_bkm}{
Use this function if you want to replace a paragraph containing
a bookmark with a flextable. As a side effect, the bookmark will be lost.
}
\examples{
library(officer)
# autonum for caption
autonum <- run_autonum(seq_id = "tab", bkm = "mtcars")
ftab <- flextable(head(mtcars))
ftab <- set_caption(ftab, caption = "mtcars data", autonum = autonum)
ftab <- autofit(ftab)
doc <- read_docx()
doc <- body_add_flextable(doc, value = ftab)
fileout <- tempfile(fileext = ".docx")
# fileout <- "test.docx" # uncomment to write in your working directory
print(doc, target = fileout)
}
|