Flextable Word输出 – 如何在不同页面上显示每个表格?

huangapple go评论60阅读模式
英文:

Flextable Word output - How to display each table on a different page?

问题

我有几张表格想要保存在Word文档中。

具体来说,我想要在不同的页面上显示每张表格。

我该如何做到这一点?

library(flextable)
head(mtcars)
FT = flextable(head(mtcars))
save_as_docx(values = list(FT, FT), path = "result.docx")
英文:

I have several tables that I want to save in a Word document.

Specifically, I would like to display each table on a different page.

How can I do this?

library(flextable)
head(mtcars)
FT=flextable(head(mtcars))
save_as_docx(values=list(FT,FT),path="result.docx")  

答案1

得分: 1

officer是一个可能的解决方案:

library(officer)
library(flextable)
head(mtcars)
FT = flextable(head(mtcars))
read_docx() |>
  body_add_flextable(FT) |>
  body_add_break() |>
  body_add_flextable(FT) |>
  body_add_break() |>
  print(target="result.docx")
英文:

officer is a possible solution:

library(officer)
library(flextable)
head(mtcars)
FT=flextable(head(mtcars))
read_docx() |> 
  body_add_flextable(FT) |> 
  body_add_break() |> 
  body_add_flextable(FT) |> 
  body_add_break() |> 
  print(target="result.docx")  

huangapple
  • 本文由 发表于 2023年4月4日 15:54:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75926821.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定