【问题标题】:Address and manipulate text in a textfield and footer in Word documents with R officer package使用 R 官员包在 Word 文档中的文本字段和页脚中处理和处理文本
【发布时间】:2019-11-22 20:45:08
【问题描述】:

我正在研究一种解决方案,以更改具有相似结构的多个 Word 文档中的文本。我要更改的文本位置是 1。在与页眉/页脚和第一个页脚中的第二个相关的文本字段中。我不知道如何处理这些元素中的文本,有人吗?有可能吗? Image of that document 这是我的例子:

library(officer)
library(magrittr)

docact <- read_docx("PATH/officertest/textfieldfooter.docx")

docx_summary(docact)

doc_index content_type style_name 文本级别 num_id 1 1 段 NA 这里是一些易于处理和操作的其他文本。不不不

cursor_reach(docact, keyword = "I want to address this textfield") %>%
  slip_in_text("This is the text that I want to add ", pos = "after", style = "Default Paragraph Font")

给出一个错误:我想解决这个文本字段在文档中没有找到

headers_replace_all_text(docact, "footertext", "the text that should be the replacement",
         only_at_cursor = FALSE,
         warn = TRUE)

警告信息: 1: 在 header$replace_all_text(old_value, new_value, only_at_cursor, : 在文档中找到 0 个“footertext”实例。 2: 在 header$replace_all_text(old_value, new_value, only_at_cursor, : 在文档中找到 0 个“footertext”实例。 3: 在 header$replace_all_text(old_value, new_value, only_at_cursor, : 在文档中找到 0 个“footertext”实例。

【问题讨论】:

    标签: r officer


    【解决方案1】:

    我觉得你在officer包里需要这个功能:

    docact &lt;- footers_replace_all_text(docact,"old_value","new_value")

    替换文本字段中的文本尚不适合我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-18
      • 1970-01-01
      • 2017-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多