Title: | Insert 'gt' Tables into Word Documents |
---|---|
Description: | Insert tables created by the 'gt' R package into 'Microsoft Word' documents. This gives users the ability to add to their existing word documents the tables made in 'gt' using the familiar 'officer' package and syntax from the 'officeverse'. |
Authors: | Ellis Hughes [aut, cre]
|
Maintainer: | Ellis Hughes <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.1.2 |
Built: | 2025-01-25 03:19:06 UTC |
Source: | https://github.com/cran/gto |
Add a 'gt' table into a Word document. The table will be processed using the as_word function then inserted either after, before, or on the cursor location.
body_add_gt( x, value, align = "center", pos = c("after", "before", "on"), caption_location = c("top", "bottom", "embed"), caption_align = "left", split = FALSE, keep_with_next = TRUE )
body_add_gt( x, value, align = "center", pos = c("after", "before", "on"), caption_location = c("top", "bottom", "embed"), caption_align = "left", split = FALSE, keep_with_next = TRUE )
x |
'rdocx' object |
value |
'gt_tbl' object |
align |
left, center (default) or right. |
pos |
where to add the gt table relative to the cursor, one of "after" (default), "before", "on" (end of line). |
caption_location |
top (default), bottom, or embed indicating if the title and subtitle should be listed above, below, or be embedded in the table |
caption_align |
left (default), center, or right. Alignment of caption (title and subtitle). Used when 'caption_location' is not "embed". |
split |
set to TRUE if you want to activate Word option 'Allow row to break across pages'. |
keep_with_next |
Word option 'keep rows together' can be activated when TRUE. It avoids page break within tables. |
An updated rdocx object with a 'gt' table inserted
flextable::body_add_flextable()
library(officer) library(gt) gt_tbl <- gt(head(exibble)) doc <- read_docx() doc <- body_add_gt(doc, value = gt_tbl) fileout <- tempfile(fileext = ".docx") print(doc, target = fileout)
library(officer) library(gt) gt_tbl <- gt(head(exibble)) doc <- read_docx() doc <- body_add_gt(doc, value = gt_tbl) fileout <- tempfile(fileext = ".docx") print(doc, target = fileout)