# officer v0.3.2

0

Monthly downloads

0th

Percentile

## Manipulation of Microsoft Word and PowerPoint Documents

Access and manipulate 'Microsoft Word' and 'Microsoft PowerPoint' documents from R. The package focuses on tabular and graphical reporting from R; it also provides two functions that let users get document content into data objects. A set of functions lets add and remove images, tables and paragraphs of text in new or existing documents. When working with 'PowerPoint' presentations, slides can be added or removed; shapes inside slides can also be added or removed. When working with 'Word' documents, a cursor can be used to help insert or delete content at a specific location in the document. The package does not require any installation of Microsoft products to be able to write Microsoft files.

# officer R package

The officer package lets R users manipulate Word (.docx) and PowerPoint (*.pptx) documents. In short, one can add images, tables and text into documents from R. An initial document can be provided; contents, styles and properties of the original document will then be available.

This package is close to ReporteRs as it produces Word and PowerPoint files but it is faster, do not require rJava and is easier to maintain.

Make corporate reporting with minimum hassle

## Word documents

The read_docx() function will read an initial Word document (an empty one by default) and let you modify its content later.

The package provides functions to add R outputs into a Word document:

• images: produce your plot in png or emf files and add them into the document, as a whole paragraph or inside a paragraph.
• tables: add data.frames as tables, format is defined by the associated Word table style.
• text: add text as paragraphs or inside an existing paragraph, format is defined by the associated Word paragraph and text styles.
• field codes: add Word field codes inside paragraphs. Field codes is an old feature of MS Word to create calculated elements such as tables of contents, automatic numbering and hyperlinks.

In a Word document, one can use cursor functions to reach the beginning or end of a document, or a particular paragraph containing a given text. This cursor concept has been implemented to make the post processing of files easier.

File generation is performed with the print function.

### import Word document in a data.frame

The function docx_summary() reads and imports content of a Word document into a tibble object. The function handles paragraphs, tables and section breaks.

## PowerPoint documents

The function read_pptx() will read an initial PowerPoint document (an empty one by default) and let you modify its content later.

The package provides functions to add R outputs into existing or new PowerPoint slides:

• images: produce your plot in png or emf files and add them in a slide.
• tables: add data.frames as tables, format is defined by the associated PowerPoint table style.
• text: add text as paragraphs or inside an existing paragraph, format is defined in the corresponding layout of the slide.

In a PowerPoint document, one can set a slide as selected and reach a particular shape (and remove it or add text).

File generation is performed with the print() function.

### import PowerPoint document in a data.frame

The pptx_summary() function reads and imports content of a PowerPoint document into a tibble object. The function handles paragraphs, tables and images.

## Extensions

### Tables and package flextable

The package flextable brings a full API to produce nice tables and use them with officer. Tables can be written in PowerPoint documents and Word documents. An option is available to render flextables in rmarkdown (HTML and Word outputs).

### Vector graphics with package rvg

The package rvg brings an API to produce nice vector graphics that can be embedded in PowerPoint documents or Excel workbooks with officer.

### Native office charts with package mschart

The package mschart combined with officer can produce native office charts in PowerPoint and Word documents.

## Installation

You can get the development version from GitHub:

devtools::install_github("davidgohel/officer")


Or the latest version on CRAN:

install.packages("officer")


## Resources

### Online documentation

The help pages are located at https://davidgohel.github.io/officer/.

### Getting help

This project is developed and maintained on my own time. In order to help me to maintain the package, do not send me private emails if you only have questions about how to use the package. Instead, visit Stackoverflow, officer has its own tag Stackoverflow link! I usually read them and answer when possible.

## Contributing to the package

### Code of Conduct

Anyone getting involved in this package agrees to our Code of Conduct.

### Bug reports

When you file a bug report, please spend some time making it easy for me to follow and reproduce. The more time you spend on making the bug report coherent, the more time I can dedicate to investigate the bug as opposed to the bug report.

### Contributing to the package development

A great way to start is to contribute an example or improve the documentation.

If you want to submit a Pull Request to integrate functions of yours, please provide:

• the new function(s) with code and roxygen tags (with examples)
• a new section in the appropriate vignette that describes how to use the new function
• add corresponding tests in directory tests/testthat.

By using rhub (run rhub::check_for_cran()), you will see if everything is ok. When submitted, the PR will be evaluated automatically on travis and appveyor and you will be able to see if something broke.

## Functions in officer

 Name Description body_replace_text_at_bkm replace text at a bookmark location docx_dim Word page layout body_end_section add section docx_reference_img add images into an rdocx object ftext formatted text pack_folder compress a folder fpar concatenate formatted text docx_body_relationship body xml document ph_add_fpar append fpar ph_with_text add text into a new shape ph_with_table add table doc_properties read document properties layout_summary presentation layouts summary ph_add_par append paragraph ph_add_text append text layout_properties slide layout properties wml_link_images transform an xml string with images references color_scheme color scheme cursor_begin set cursor in an rdocx object sheet_select select sheet fp_sign object unique signature docx_body_xml body xml document fp_cell Cell formatting properties shortcuts shortcuts for formatting properties fp_par Paragraph formatting properties body_replace_all_text Replace text anywhere in the document, or at a cursor docx_bookmarks List Word bookmarks officer officer: Manipulate Microsoft Word and PowerPoint Documents on_slide change current slide ph_with_ul add unordered list to a pptx presentation ph_with_gg add ggplot to a pptx presentation fp_text Text formatting properties docx_show_chunk Show underlying text tag structure read_xlsx open a connexion to an 'Excel' file ph_with_img add image pptx_summary get PowerPoint content in a tidy format remove_slide remove a slide unpack_folder Extract files from a zip file docx_summary get Word content in a tidy format styles_info read Word styles ph_empty add a new empty shape external_img external image media_extract Extract media from a document object fp_border border properties object slide_summary get PowerPoint slide content in a tidy format move_slide move a slide ph_from_xml add an xml string as new shape ph_slidelink slide link to a placeholder ph_hyperlink hyperlink a placeholder break_column_before add a column break ph_remove remove shape slip_in_seqfield append seq field read_pptx open a connexion to a 'PowerPoint' file slip_in_xml add a wml string into a Word document stext Word styled text ph_with_fpars_at add multiple formated paragraphs read_docx open a connection to a 'Word' file slip_in_text append text sections sections set_doc_properties set document properties slip_in_footnote append a footnote slip_in_img append an image body_add_docx insert an external docx body_add_fpar add fpar add_sheet add a sheet add_slide add a slide block_list list of blocks annotate_base annotate PowerPoint base document body_add_blocks add a list of blocks into a document body_bookmark add bookmark body_add_break add page break body_add_gg add ggplot change_styles replace paragraphs styles body_add_toc add table of content body_add_xml add an xml string as document element body_add_table add table body_add_par add paragraph of text body_add_img add image body_remove remove an element No Results!

## Vignettes of officer

 Name officer_reader.Rmd powerpoint.Rmd word.Rmd No Results!

## Details

 Type Package License GPL-3 LazyData TRUE LinkingTo Rcpp URL https://davidgohel.github.io/officer BugReports https://github.com/davidgohel/officer/issues RoxygenNote 6.0.1.9000 VignetteBuilder knitr NeedsCompilation yes Packaged 2018-07-23 08:03:56 UTC; davidgohel Repository CRAN Date/Publication 2018-07-23 09:10:03 UTC
 imports base64enc , digest , grDevices , htmltools , magrittr , R6 , Rcpp (>= 0.12.12) , stats , utils , uuid , xml2 (>= 1.1.0) , zip suggests devEMF , ggplot2 , knitr , rmarkdown , testthat , tibble Contributors Jon Calder, Frank Hangler, Liz Sander, John Harrold