library(officer)
doc <- read_docx()
doc <- docx_set_paragraph_style(
doc,
style_id = "rightaligned",
style_name = "Explicit label",
fp_p = fp_par(text.align = "right", padding = 20),
fp_t = fp_text_lite(
bold = TRUE,
shading.color = "#FD34F0",
color = "white")
)
doc <- body_add_par(doc,
value = "This is a test",
style = "Explicit label")
docx_file <- print(doc, target = tempfile(fileext = ".docx"))
docx_file
Run the code above in your browser using DataLab