Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/elipousson/officerextras

🏢 A R package with {officer} helper functions.
https://github.com/elipousson/officerextras

microsoft-word officer r-package rstats

Last synced: 10 days ago
JSON representation

🏢 A R package with {officer} helper functions.

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# officerExtras officerExtras website

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![Codecov test coverage](https://codecov.io/gh/elipousson/officerExtras/branch/main/graph/badge.svg)](https://app.codecov.io/gh/elipousson/officerExtras?branch=main)

The goal of officerExtras is to provide helper and convenience functions for the [{officer}](https://github.com/davidgohel/officer) package.

## Installation

You can install the development version of officerExtras like so:

``` r
pak::pkg_install("elipousson/officerExtras")
```

## Usage

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:

```{r read_officer}
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()`.

```{r write_officer}
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)
})
```

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:

```{r convert_docx}
convert_docx(docx, to = "markdown")
```

## Related projects

There are a number of related projects for extending officer or working with [OOXML](https://en.wikipedia.org/wiki/Office_Open_XML) in R and other languages.

### Extending officer

- [gto](https://github.com/GSK-Biostatistics/gto): allow users to insert gt tables into officeverse.
- [onbrand](https://github.com/john-harrold/onbrand): A R package to provide a systematic method to script support for different Word of PowerPoint templates.
- [officerWinTools](https://github.com/joshmire/officerWinTools): A R package to complement the officer package when using Microsoft Office in a Windows environment.

### Working with Microsoft Office documents with R

- [docxtractr](https://github.com/hrbrmstr/docxtractr): Extract Tables from Microsoft Word Documents with R
- [stylex](https://github.com/niszet/stylex): A R package to help update docx style files.
- [deef](https://github.com/prcleary/deef): Data extractor scripts for electronic forms, compatible with Microsoft Word files.

### Other tools for working with Microsoft Office documents

- [python-docx](https://github.com/python-openxml/python-docx):Create and modify Word documents with Python
- [Docx-templates](https://github.com/guigrpa/docx-templates): Template-based docx report creation for both Node and the browser
- [docx](https://github.com/dolanmiu/docx): Easily generate and modify .docx files with JS/TS. Works for Node and on the Browser.
- [docxtemplater](https://github.com/open-xml-templating/docxtemplater): Generate docx, pptx, and xlsx from templates (Word, Powerpoint and Excel documents), from Node.js, the Browser and the command line