write_and_open: Alternative to default 'officer' print() function. Write the...

View source: R/officer.R

write_and_openR Documentation

Alternative to default officer print() function. Write the file and try to open it right away.

Description

As it tests if the file is writable, this function also prevents officer:::print.rdocx() to abort the RStudio session.

Usage

write_and_open(doc, docx.file)

Arguments

doc

the docx object

docx.file

the name of the target file. If missing or NULL, the doc will open in a temporary file.

Value

Nothing, called for its side effects

Author(s)

Dan Chaltiel

Examples

library(officer)
library(crosstable)
mytable = crosstable(mtcars2)
doc = read_docx() %>%
    body_add_crosstable(mytable)

write_and_open(doc)
## Not run: 
write_and_open(doc, "example.docx")

## End(Not run)

crosstable documentation built on Nov. 13, 2023, 1:08 a.m.