library(officer)
## Warning: package 'officer' was built under R version 4.1.0
library(magrittr)
doc_1 <- read_docx() %>%
body_add_par("Hello world!", style = "centered") %>%
body_add_par("", style = "Normal") %>%
body_add_table(airquality, style = "table_template")
print(doc_1, target = "example_3.docx")
styles_info(doc_1)
## style_type style_id style_name is_custom is_default
## 1 paragraph Normal Normal FALSE TRUE
## 2 paragraph Titre1 heading 1 FALSE FALSE
## 3 paragraph Titre2 heading 2 FALSE FALSE
## 4 paragraph Titre3 heading 3 FALSE FALSE
## 5 character Policepardfaut Default Paragraph Font FALSE TRUE
## 6 table TableauNormal Normal Table FALSE TRUE
## 7 numbering Aucuneliste No List FALSE TRUE
## 8 character strong strong TRUE FALSE
## 9 paragraph centered centered TRUE FALSE
## 10 table tabletemplate table_template TRUE FALSE
## 11 table Listeclaire-Accent2 Light List Accent 2 FALSE FALSE
## 12 character Titre1Car Titre 1 Car TRUE FALSE
## 13 character Titre2Car Titre 2 Car TRUE FALSE
## 14 character Titre3Car Titre 3 Car TRUE FALSE
## 15 paragraph ImageCaption Image Caption TRUE FALSE
## 16 paragraph TableCaption Table Caption TRUE FALSE
## 17 table Tableauprofessionnel Table Professional FALSE FALSE
## 18 paragraph TM1 toc 1 FALSE FALSE
## 19 paragraph TM2 toc 2 FALSE FALSE
## 20 paragraph Textedebulles Balloon Text FALSE FALSE
## 21 character TextedebullesCar Texte de bulles Car TRUE FALSE
## 22 character referenceid reference_id TRUE FALSE
## 23 paragraph graphictitle graphic title TRUE FALSE
## 24 paragraph tabletitle table title TRUE FALSE
#ref https://ardata-fr.github.io/officeverse/officedown-for-word.html#add-blocks
#https://stackoverflow.com/questions/25425993/data-frame-to-word-table