Skip to contents

Working with Word documents

read_docx()
Create a 'Word' document object
print(<rdocx>)
Write a 'Word' File
set_doc_properties()
Set document properties
docx_set_paragraph_style()
Add or replace paragraph style in a Word document
docx_set_character_style()
Add character style in a Word document
docx_embed_font()
Embed Fonts in a Word Document
docx_set_settings()
Set 'Microsoft Word' Document Settings
change_styles()
Replace styles in a 'Word' Document

Word documents information

docx_summary()
Get Word content in a data.frame
docx_comments()
Get comments in a Word document as a data.frame
styles_info()
Read 'Word' styles
doc_properties()
Read document properties
docx_dim()
'Word' page layout
docx_show_chunk()
Show underlying text tag structure
length(<rdocx>)
Number of blocks inside an rdocx object

Add content to Word documents

body_add_blocks()
Add a list of blocks into a 'Word' document
body_add_list()
Add a list of items into a 'Word' document
body_add_caption()
Add Word caption in a 'Word' document
body_add_img()
Add an image in a 'Word' document
body_add_par()
Add paragraphs of text in a 'Word' document
body_add_table()
Add table in a 'Word' document
body_add_fpar()
Add fpar in a 'Word' document
body_add_toc()
Add table of content in a 'Word' document
body_add_break()
Add a page break in a 'Word' document
body_add_docx()
Add an external docx in a 'Word' document
body_import_docx()
Import an external docx in a 'Word' document
body_bookmark()
Add bookmark in a 'Word' document
body_add_gg()
Add a 'ggplot' in a 'Word' document
body_add_plot()
Add plot in a 'Word' document
body_comment()
Add comment in a 'Word' document
body_append_start_context() write_elements_to_context() body_append_stop_context()
Fast Append context to a Word document

Word sections

prop_section()
Section properties
page_mar()
Page margins object
page_size()
Page size object
section_columns()
Section columns
body_set_default_section()
Define Default Section
body_end_block_section()
Add any section
body_end_section_columns()
Add multi columns section
body_end_section_columns_landscape()
Add a landscape multi columns section
body_end_section_continuous()
Add continuous section
body_end_section_landscape()
Add landscape section
body_end_section_portrait()
Add portrait section

Word simple tables

prop_table()
Table properties
table_colwidths()
Column widths of a table
table_conditional_formatting()
Table conditional formatting
table_layout()
Algorithm for table layout
table_stylenames()
Paragraph styles for columns
table_width()
Preferred width for a table

Replace content in Word documents

Remove content from Word documents

body_remove()
Remove an element in a 'Word' document

Reading/writing PowerPoint documents

read_pptx()
Create a 'PowerPoint' document object
print(<rpptx>)
Write a 'PowerPoint' file.

Manipulate slides

add_slide()
Add a slide
layout_default()
Default layout for new slides
on_slide()
Change current slide
move_slide()
Move a slide
remove_slide()
Remove slide(s)
`slide_visible<-`() slide_visible()
Get or set slide visibility

Slide content

ph_with() ph_with.character() ph_with.numeric() ph_with.factor() ph_with.logical() ph_with.Date() ph_with.block_list() ph_with.unordered_list() ph_with.block_list_items() ph_with.data.frame() ph_with.gg() ph_with.plot_instr() ph_with.external_img() ph_with.fpar() ph_with.empty_content() ph_with.xml_document()
Add objects on the current slide
phs_with()
Fill multiple placeholders using key value syntax
ph_location()
Location for a placeholder from scratch
ph_location_fullsize()
Location of a full size element
ph_location_id()
Location of a placeholder based on its id
ph_location_label()
Location of a named placeholder
ph_location_left()
Location of a left body element
ph_location_right()
Location of a right body element
ph_location_template()
Location for a placeholder based on a template
ph_location_type()
Location of a placeholder based on a type
ph_slidelink()
Slide link to a placeholder
ph_hyperlink()
Hyperlink a placeholder
ph_remove()
Remove a shape
empty_content()
Empty block for 'PowerPoint'
sp_line() print(<sp_line>) update(<sp_line>)
Line properties
sp_lineend() print(<sp_lineend>) update(<sp_lineend>)
Line end properties
set_notes()
Set notes for current slide
notes_location_label()
Location of a named placeholder for notes
notes_location_type()
Location of a placeholder for notes

Read PowerPoint information

pptx_summary()
PowerPoint content in a data.frame
slide_size()
Slides width and height
length(<rpptx>)
Number of slides
annotate_base()
Placeholder parameters annotation
layout_summary()
Presentation layouts summary
layout_properties()
Slide layout properties
plot_layout_properties()
Slide layout properties plot
layout_dedupe_ph_labels()
Detect and handle duplicate placeholder labels
layout_rename_ph_labels() `layout_rename_ph_labels<-`()
Change ph labels in a layout
slide_summary()
Slide content in a data.frame
color_scheme()
Color scheme of a PowerPoint file
media_extract()
Extract media from a document object
as.matrix(<rpptx>)
PowerPoint table to matrix

Content formatting

Define formatted paragraphs or parts of paragraphs, such as text, calculated Word fields, images, or sets of paragraphs. The four sub-sections below go from the atomic formatting specs (properties) up to the composite blocks.

Properties

Atomic formatting specs consumed by runs, paragraphs and table cells (font, colour, borders, alignment, tab stops, etc.).

fp_text() fp_text_lite() format(<fp_text>) print(<fp_text>) update(<fp_text>)
Text formatting properties
fp_par() fp_par_lite() print(<fp_par>) update(<fp_par>)
Paragraph formatting properties
fp_border() update(<fp_border>)
Border properties object
fp_cell() format(<fp_cell>) print(<fp_cell>) update(<fp_cell>)
Cell formatting properties
fp_tabs()
Tabs properties object
fp_tab()
Tabulation mark properties object

Runs

A run is a piece of text inside a paragraph with homogeneous formatting. Runs include plain formatted text, line breaks, hyperlinks, bookmarks, footnotes and Word fields.

ftext()
Formatted chunk of text
hyperlink_ftext()
Formatted chunk of text with hyperlink
run_autonum()
Auto number
run_bookmark()
Bookmark for 'Word'
run_columnbreak()
Column break for 'Word'
run_comment()
Comment for 'Word'
run_footnote()
Footnote for 'Word'
run_footnoteref()
Word footnote reference
run_linebreak()
Page break for 'Word'
run_pagebreak()
Page break for 'Word'
run_reference()
Cross reference
run_tab()
Tab for 'Word'
run_word_field() run_seqfield()
'Word' computed field
run_wordtext()
Word chunk of text with a style
set_autonum_bookmark()
Update bookmark of an autonumber run

Blocks

A block is a paragraph-level element (paragraph, caption, table, list, section, pour, table of contents) that can be added to the body of a Word document or to a PowerPoint placeholder.

fpar() update(<fpar>)
Formatted paragraph
block_caption()
Caption block
block_gg()
'ggplot' block
block_list()
List of blocks
block_list_items()
List of items for Word and PowerPoint
block_pour_docx()
External Word document placeholder
block_section()
Section for 'Word'
block_table()
Table block
block_toc()
Table of content for 'Word'
list_item()
Create a list item
unordered_list()
Unordered list
plot_instr()
Wrap plot instructions for png plotting in Powerpoint or Word

Images

Raster images embedded either inline in a paragraph or anchored as a floating element.

external_img()
External image
floating_external_img()
Floating external image

RTF

rtf_doc()
Create an RTF document object
rtf_add()
Add content into an RTF document
print(<rtf>)
Write an 'RTF' File

Excel

read_xlsx() length(<rxlsx>) print(<rxlsx>)
Create an 'Excel' document object
add_sheet()
Add a sheet
sheet_names()
Sheet names of an xlsx workbook
sheet_select()
Select sheet
sheet_remove()
Remove a sheet
sheet_write_data()
Write data to a sheet
sheet_add_drawing()
Add a drawing to an Excel sheet

Misc

officer-package officer
Manipulate Microsoft Word and PowerPoint Documents with 'officer'
open_file()
Opens a file locally
shortcuts
shortcuts for formatting properties