officer v0.1.5
Monthly downloads
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.
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")
Functions in officer
Name | Description | |
add_slide | add a slide | |
body_add_break | add page break | |
body_add_fpar | add fpar | |
body_add_gg | add ggplot | |
external_img | external image | |
fp_border | border properties object | |
layout_properties | slide layout properties | |
layout_summary | presentation layouts summary | |
doc_properties | read document properties | |
docx_dim | Word page layout | |
fp_sign | object unique signature | |
fp_text | Text formatting properties | |
pack_folder | compress a folder | |
ph_add_fpar | append fpar | |
set_doc_properties | set document properties | |
shortcuts | shortcuts for formatting properties | |
body_add_xml | add an xml string as document element | |
body_bookmark | add bookmark | |
body_end_section | add section | |
body_remove | remove an element | |
body_add_img | add image | |
body_add_par | add paragraph of text | |
docx_reference_img | add images into an rdocx object | |
docx_summary | get Word content in a tidy format | |
fp_cell | Cell formatting properties | |
fp_par | Paragraph formatting properties | |
ph_hyperlink | hyperlink a placeholder | |
ph_remove | remove shape | |
pptx_summary | get PowerPoint content in a tidy format | |
body_add_table | add table | |
body_add_toc | add table of content | |
color_scheme | color scheme | |
cursor_begin | set cursor in an rdocx object | |
media_extract | Extract media from a document object | |
on_slide | change current slide | |
ph_add_par | append paragraph | |
read_docx | open a connexion to a 'Word' file | |
slip_in_seqfield | append seq field | |
slip_in_text | append text | |
ph_add_text | append text | |
ph_with_table | add table | |
ph_with_text | add text into a new shape | |
slip_in_xml | add a wml string into a Word document | |
ph_empty | add a new empty shape | |
ph_from_xml | add an xml string as new shape | |
read_pptx | open a connexion to a 'PowerPoint' file | |
remove_slide | remove a slide | |
unpack_folder | Extract files from a zip file | |
wml_link_images | transform an xml string with images references | |
styles_info | read Word styles | |
fpar | concatenate formatted text | |
ftext | formatted text | |
ph_slidelink | slide link to a placeholder | |
ph_with_img | add image | |
slide_summary | get PowerPoint slide content in a tidy format | |
slip_in_img | append an image | |
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, gdtools |
URL | https://davidgohel.github.io/officer |
BugReports | https://github.com/davidgohel/officer/issues |
RoxygenNote | 6.0.1.9000 |
VignetteBuilder | knitr |
NeedsCompilation | yes |
Packaged | 2017-07-26 12:19:26 UTC; davidgohel |
Repository | CRAN |
Date/Publication | 2017-07-27 21:52:00 UTC |
Include our badge in your README
[](http://www.rdocumentation.org/packages/officer)