如何使用高级职员R包自动更新表格/数字表格

时间:2018-10-29 23:07:56

标签: r officer

在使用Officer R软件包时,我无法使表自动更新以显示实际表号。我已经尝试过包装示例代码:

library(magrittr)
library(officer)
x <- officer::read_docx(Template) %>% # Make sure to set your template file
  body_add_par("Time is: ", style = 'Normal') %>%
  slip_in_seqfield(
      str = "TIME \u005C@ \"HH:mm:ss\" \u005C* MERGEFORMAT",
      style = 'Subtle Emphasis') %>%

  body_add_par(" - This is a tbl title", style = 'caption') %>%
  slip_in_seqfield(str = "SEQ Table \u005C* arabic",
                   style = 'Subtle Emphasis', pos = "before") %>%
  slip_in_text("Table ", style = 'Subtle Emphasis', pos = "before") %>%

  body_add_par(" - This is another tbl title", style = 'caption') %>%
  slip_in_seqfield(str = "SEQ Table \u005C* arabic",
                   style = 'Subtle Emphasis', pos = "before")  %>%
  slip_in_text("Table ", style = 'Subtle Emphasis', pos = "before") %>%
  body_add_par("This is a symbol: ", style = "Normal") %>%
  slip_in_seqfield(str = "SYMBOL 100 \u005Cf Wingdings",
                   style = 'Subtle Emphasis')

print(x, target = "TestOut.docx")

但是生成的word文档中的表格表格仅显示了此内容(看不到实际数字,只是一个空格):

Table  - This is a tbl title................................1
Table  - This is another tbl title..........................1

数字确实出现在实际的表标题中,只是没有出现在该表的表中。我需要自动更新此表格以使数字显示出来吗?

0 个答案:

没有答案