The goal of officerExtras is to provide helper and convenience functions for the {officer} package.
You can install the development version of officerExtras like so:
pak::pkg_install("elipousson/officerExtras")
The officerExtras package provides a variety of helper functions to
simplify the process of working with officer. For example, a single
read_officer()
function works with docx, pptx, or xlsx files:
library(officerExtras)
docx <- read_officer(filename = "example.docx", path = system.file("doc_examples", package = "officer"))
pptx <- read_officer(filename = "example.pptx", path = system.file("doc_examples", package = "officer"))
officer uses a print method to save rdocx, rpptx, or rxlsx objects back
to files. officerExtras provides a write_officer()
with that adds the
option to pass a filename and path separately and pass document
properties to officer::doc_properties()
.
withr::with_tempdir({
write_officer(docx, "write-example.docx", modified_by = "officerExtras", title = "Document Title set by doc_properties", subject = "Microsoft Word, R")
example_docx <- read_officer("write-example.docx")
officer::doc_properties(example_docx)
})
#> tag value
#> 1 title Document Title set by doc_properties
#> 2 subject Microsoft Word, R
#> 3 creator author
#> 4 keywords
#> 5 description these are comments
#> 6 lastModifiedBy officerExtras
#> 7 revision 12
#> 8 created 2017-04-26T13:10:00Z
#> 9 modified 2023-06-22T11:04:39Z
#> 10 category
The package also wraps useful functions from a few other packages.
convert_docx()
uses rmarkdown::pandoc_convert()
to convert a rdocx
object or a Word document to any other pandoc supported output format:
convert_docx(docx, to = "markdown")
There are a number of related projects for extending officer or working with OOXML in R and other languages.
- gto: allow users to insert gt tables into officeverse.
- onbrand: A R package to provide a systematic method to script support for different Word of PowerPoint templates.
- officerWinTools: A R package to complement the officer package when using Microsoft Office in a Windows environment.
- docxtractr: Extract Tables from Microsoft Word Documents with R
- stylex: A R package to help update docx style files.
- deef: Data extractor scripts for electronic forms, compatible with Microsoft Word files.
- python-docx:Create and modify Word documents with Python
- Docx-templates: Template-based docx report creation for both Node and the browser
- docx: Easily generate and modify .docx files with JS/TS. Works for Node and on the Browser.
- docxtemplater: Generate docx, pptx, and xlsx from templates (Word, Powerpoint and Excel documents), from Node.js, the Browser and the command line