1

我面临以下问题:我从 R 中的数据框创建了一个漂亮的弹性表,我想通过电子邮件发送。我使用 htmltools_value 来获取 flextable 的 HTML 代码。现在我可以将它作为 htmlbody 嵌入到我的电子邮件中,从某种意义上说,我成功发送了电子邮件。但是,电子邮件丢失了所有颜色和边框,其余格式仍与弹性表中定义的一样。任何人都遇到过类似的问题或知道可能是什么问题?

    require(flextable)
    require(RDCOMClient)

    header_col2 <- c("","","", "", "2nd header", "2nd header","More headers", "More headers", "More headers", "More headers") 
    dfTest <- mtcars[c(1:6),c(1:10)] 
    ft <- flextable(dfTest) 
    ft <- add_header_row(ft,values = header_col2,top = T,colwidths = c(rep(1,10))) ft <- merge_h(ft, part = "header") 
    ft <-bold(ft, bold=T, part="header") 
    ft <-theme_zebra(ft,odd_header = 'red', even_header = 'grey', odd_body   = 'lightblue', even_body = "white") 
    ft <- color(ft, color = "white", part = "header") 
    ft <- bold(ft, bold = TRUE, part = "header") 
    ft <- fontsize(ft, size = 11, part = "header") 
    std_border = fp_border(color="white", width = 1.5) 
    big_border = fp_border(color="gray", width = 1) 
    ft <- border_outer(ft, part="all", border = big_border ) 
    ft <- border_inner_v(ft, part="header", border = std_border ) 
    body <- htmltools_value(ft)
    # or body <- format(ft, type = "html") 
OutApp <- COMCreate("Outlook.Application") 
outMail = OutApp$CreateItem(0) 
outMail[["To"]] = "test@test.com" 
outMail[["subject"]] = "TEST" 
outMail[["HTMLbody"]] = body 
outMail$Send()
4

0 回答 0