1

次の問題に直面しています: R のデータフレームから美しいフレックステーブルを作成しました。これをメールで送信したいと思います。htmltools_value を使用して、フレックステーブルの 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