officer is an R package for manipulating Word (.docx) and PowerPoint (*.pptx) documents.
Questions tagged [officer]
413 questions
4
votes
1 answer
Possibility to combine openxlsx-Workbook and xl_add_vg from rvg - Export editable graphics
I want to export some tables and ggplot-graphics from a shiny app in an excel-file. Until now I worked with openxlsx, adding many sheets and content. Now I want to export a ggplot as editable vector graphic to Excel. This is well feasible with…

ulrike niemann
- 43
- 5
4
votes
1 answer
Export data.table and print cells content in new lines
Let's have a data frame:
df <- data.frame(c('Warsaw; Nairobi'),c('Mogadishu; Ottawa'),c('Berlin; Paris'))
colnames(df)<-c('a','b','c')
Now it is time to export data to table .docx
library(officer)
library(flextable)
library(magrittr)
my_doc <-…

Mikołaj
- 385
- 4
- 17
4
votes
0 answers
Replacing text within PPT slides and charts
I've got a PPT template that has around 20 slides. Within the slides, there are shapes, tables and charts that I need to update.
In a lot of cases, it is as simple as: find and replace "xx" in Shape 123 with textABC.
I've been looking at the…

RLearner101
- 101
- 4
4
votes
1 answer
Changing Word document style in RMarkdown
I am attempting to manually change the style within an R-markdown document. In the example below I have created a reference_docx with the style named Highlight
---
title: "My Title"
output:
bookdown::word_document2:
fig_caption: yes
…

Patrick
- 915
- 2
- 9
- 26
4
votes
1 answer
How to remove the number in "Heading 1" - officeR
Is it possible to remove the number when I add a heading in a word document?
my_doc <- read_docx() %>%
body_add_par("This is a heading", style = "heading 1")
print(my_doc, target = 'dummy.docx')
The result in word is 1. This is a heading
But I…

Bruno Guarita
- 767
- 10
- 21
4
votes
1 answer
Officer - Format text
I am trying to change the font size of a paragraph using Officer but I am not able to do it. Can anyone tell me what I am doing wrong?
library(officer)
text_style <- fp_text(font.size = 12)
my_doc <- read_docx()
body_add_par(my_doc,"This is a…

Bruno Guarita
- 767
- 10
- 21
4
votes
1 answer
group a flextable, a ggplot, a text and an image together into a grid object, then add it to a powerpoint slide
I want to know if it's possible to group a flextable/regulartable, a ggplot, a text and an image together into a grid object, and then put that grid in a PowerPoint slide?
This could be very useful for arranging the objects inside a power point…

Popescu Gabriel
- 137
- 6
4
votes
3 answers
How to add line breaks?
I'm trying to add line breaks using body_replace_all_text or body_add_par but am having no joy. Using \r\n shows correctly in OSX TextEdit, but not in Word.
An example:
library(officer)
library(tidyverse)
read_docx() %>%
…

bjw
- 2,046
- 18
- 33
4
votes
1 answer
Removing slides of a presentation using officer package in R
I am working with officer package in R to transfer my plots as outputs to a power point presentation.
Every time I run the code, I want to make sure that there are no slides in the pptx in which I want to save my plots.
Right now I know how to…

Jawairia
- 295
- 4
- 14
4
votes
0 answers
officer method ph_empty_at add an empty placeholder specifying also an ID that can be used later to add content to it
I want to add several placeholders to a Power Point slide, in different (fixed) positions, using a predefined template of my company. I use that template only to get the font style, the header and footer of the slides,but not for the content of each…

Popescu Gabriel
- 137
- 6
4
votes
3 answers
Modify the format of a portion of a flextable cell
I want to modify the format of a portion of a cell, while leaving the remaining text unmodified for inclusion in a .docx report:
e.g., Brill (Scophthalmus rhombus) in subdivisions 22-32 (Baltic Sea)
My data is set up with HTML tags, which I have…

Scott
- 161
- 8
3
votes
3 answers
Workaround for adding flextable including images to PowerPoint
I have seen that there is already a question about that known limitation for pptx.
But is there a workaround like converting it first into an image and import that to pptx or something similar?
I don‘t care that the table can‘t be edited afterwards,…

Swyler
- 124
- 1
- 12
3
votes
1 answer
Highlight text inline. R-markdown with reference .docx
I need to be able to highlight all text in an r-markdown document that has been inserted using an inline code chunk. E.G r TEXT.
This is to enable editing of the automated Word document creation.
I have tried using
.highlight {
background-color:…

silas
- 41
- 4
3
votes
0 answers
Using the officer package; is it possible to apply the "Shrink text on overflow" functionality from a placeholder in your ppt template?
I use officer to generate ppt presentations from a range of data sources and generally use conditional statements to control the font size on my slides based on number of characters in a string or rows in a table. However, this can be tedious and is…

Misfit6
- 39
- 1
3
votes
0 answers
Officer ggplot2 charts have bolded text when using some templates and rvg
This is a difficult issue to debug as the issue appears to arise from a quirk of the underlying template.
My summary of the issue is that ggplot2 charts have bolded text when using some templates and rvg::dml . The text is not bolded when using the…

daviddiviny
- 111
- 1
- 3