html - 从 R 通过 Outlook 发送使用 rmarkdown 创建的格式化 HTML 表
问题描述
我使用 rmarkdown 创建了以下格式良好的表并保存为 table.rmd 文件。
library(RDCOMClient)
kable(mtcars[1:5, 1:6]) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
full_width = T,
position = "left",
font_size = 13,
fixed_thead = list(enabled = T, background = "#c5d9f1")) %>%
column_spec(1, bold = T, border_right = T) %>%
column_spec(2, width = "5cm", background = "yellow") %>%
row_spec(4:5, bold = T, color = "white", background = "grey")
现在,我想使用以下代码将此文件/表格作为电子邮件正文通过 Outlook 发送,同时保留表格的原始格式。
rmarkdown::render("table.Rmd", "html_document")
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "email@abc.com"
outMail[["subject"]] = paste0("Report ", Sys.Date() - 1)
df_html <- read table.html as html so that the df_html gets correctly displayed as well formatted html table.
outMail[["HTMLBody"]] = df_html
outMail$Send()
我该怎么做?我的信念是,如果我可以在 R 中将 table.html 读取为 html 本身,我就可以做到这一点。那么,如果这是正确的,我如何创建可以分配给 outMail[["HTMLBody"]] 的 df_html 以使其正常工作?
解决方案
推荐阅读
- reactjs - 用于 TextField 的 React Material-UI 自定义输入
- python - 将二维 numpy 数组附加到 txt 文件
- python - models.py 中的 Django 过滤器关系
- flask-sqlalchemy - 有没有办法在没有关联表的情况下在 Flask-SqlAlachemy 中建立多对多关系?
- c# - Microsoft HoloLens 图像捕获不起作用
- c# - 如何使用 EF Core 创建异步存储库?
- scala - Scala/Spark - 根据键查找行中的值总数
- git - 如何解析 git gpgsig 签名提交
- android - 我如何在颤动中做 TextFormField?像这样
- javascript - 尝试在 Javascript 中导入第三方库 - 得到 404