我按照这个答案中的步骤合并了两个文档Writing word documents with the officer package: How to combine several rdocx objects?
但是一个文档是一个首页,另一个文档有标题。问题是,当我加入他们的时候,首页也有标题。
如何合并或合并两个文档,同时保持页眉与frontpage的分离?
#creating the front page.
#summarized version since it will have added features
my_doc_frontpage <- read_docx()
my_doc_frontpage <- my_doc_frontpage %>%
body_add_img(src = "logo.png", width = 1, height = 0.8, style = "centered")
print(my_doc_frontpage,"frontpage.docx")
#reading the file containing some headers.
#summarized version since it will have added features
my_doc <- read_docx("base.docx")
my_doc <- body_add_docx(my_doc,"frontpage.docx")
print(my_doc,"combined.docx")但是combined.docx文件修改了头文件的frontpage
发布于 2020-10-07 05:16:35
所以,过了一段时间,我找到了解决这个问题的方法。
my_doc <- read_docx("template.docx") my_doc <- my_doc %>% headers_replace_all_text("front1",“") #空白,因为它是frontpage my_doc <- my_doc %>% headers_replace_all_text("page1","Document") #新标题
就是这样
https://stackoverflow.com/questions/63838267
复制相似问题