officer v0.1.8

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 focus 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 product to be able to write Microsoft files.

Readme

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 (but xml2) and has less functions that will make it easier to maintain.

Make corporate reporting with minimum hassle

Word documents

Function read_docx 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 content, automatic numbering and hyperlinks.

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

The file generation is performed with function print.

import Word document in a data.frame

Function docx_summary read and import content of a Word document into a tibble object. The function handles paragraphs, tables and section breaks.

PowerPoint documents

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).

The file generation is performed with function print.

import PowerPoint document in a data.frame

Function pptx_summary read and import content of a PowerPoint document into a tibble object. The function handles paragraphs, tables and images.

Tables and package flextable

The package flextable brings a full API to produce nice tables and use them with officer.

Installation

You can get the development version from GitHub:

devtools::install_github("davidgohel/officer")

Or the latest version on CRAN:

install.packages("officer")

Plan / to do list

  • enable access to headers and footers in Word documents
  • improve tests and documentation (help is more than welcome)

Functions in officer

Name Description
body_add_xml add an xml string as document element
body_bookmark add bookmark
docx_reference_img add images into an rdocx object
docx_summary get Word content in a tidy format
body_add_fpar add fpar
body_add_gg add ggplot
body_replace_at replace text at a bookmark location
color_scheme color scheme
external_img external image
fp_border border properties object
on_slide change current slide
pack_folder compress a folder
ph_with_img add image
ph_with_table add table
slip_in_img append an image
slip_in_seqfield append seq field
add_slide add a slide
body_add_break add page break
docx_bookmarks List Word bookmarks
docx_dim Word page layout
fp_sign object unique signature
body_add_img add image
body_add_par add paragraph of text
body_end_section add section
body_remove remove an element
fp_text Text formatting properties
media_extract Extract media from a document object
officer officer: Manipulate Microsoft Word and PowerPoint Documents
read_docx open a connexion to a 'Word' file
read_pptx open a connexion to a 'PowerPoint' file
shortcuts shortcuts for formatting properties
slide_summary get PowerPoint slide content in a tidy format
layout_properties slide layout properties
layout_summary presentation layouts summary
ph_add_fpar append fpar
ph_add_par append paragraph
ph_with_text add text into a new shape
pptx_summary get PowerPoint content in a tidy format
wml_link_images transform an xml string with images references
fp_cell Cell formatting properties
fp_par Paragraph formatting properties
ph_from_xml add an xml string as new shape
ph_hyperlink hyperlink a placeholder
ph_remove remove shape
body_add_table add table
body_add_toc add table of content
cursor_begin set cursor in an rdocx object
doc_properties read document properties
fpar concatenate formatted text
ftext formatted text
ph_add_text append text
ph_empty add a new empty shape
ph_slidelink slide link to a placeholder
styles_info read Word styles
unpack_folder Extract files from a zip file
remove_slide remove a slide
set_doc_properties set document properties
slip_in_text append text
slip_in_xml add a wml string into a Word document
No Results!

Vignettes of officer

Name
offcran/graphics.Rmd
offcran/tables.Rmd
officer_reader.Rmd
powerpoint.Rmd
word.Rmd
No Results!

Last month downloads

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 2017-10-05 17:45:25 UTC; davidgohel
Repository CRAN
Date/Publication 2017-10-05 22:23:38 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/officer)](http://www.rdocumentation.org/packages/officer)