officer (version 0.3.14)

read_docx: Create a 'Word' document object

Description

read and import a docx file as an R object representing the document. When no file is specified, it uses a default empty file.

Use then this object to add content to it and create Word files from R.

Usage

read_docx(path = NULL)

# S3 method for rdocx print(x, target = NULL, ...)

Arguments

path

path to the docx file to use as base document.

x

an rdocx object

target

path to the docx file to write

...

unused

styles

read_docx() uses a Word file as the initial document. This is the original Word document from which the document layout, paragraph styles, or table styles come.

You will be able to add formatted text, change the paragraph style with the R api, but it will always be easier to use the styles from the original document.

See body_add_* functions to add content.

See Also

print.rdocx, body_add_par, body_add

Examples

Run this code
# NOT RUN {
# create an rdocx object with default template ---
read_docx()

print(read_docx())
# write a rdocx object in a docx file ----
if( require(magrittr) ){
  read_docx() %>% print(target = tempfile(fileext = ".docx"))
}

# }

Run the code above in your browser using DataLab