如何在flextable中包含超链接?

问题描述 投票:0回答:2

我正在尝试使用包含其单元格中包含超链接的表的官员创建一个powerpoint文件,但我找不到如何执行此操作的方法。

例如。幻灯片上2列表格中的一行可以包含第1列中的“Ensembl”,第2列会显示“ENSG00000165025”,点击它会打开浏览器'uswest.ensembl.org/Homo_sapiens/Gene/Summary ?G = ENSG00000165025' 。第二列中的某些值可能只是纯文本。

这有可能实现吗?

r flextable officer
2个回答
0
投票

使用github上的新版本,您将能够在下面的演示中包含超链接:

library(flextable)
dat <- data.frame(
  col = "CRAN website", href = "https://cran.r-project.org",
  stringsAsFactors = FALSE)

ft <- flextable(dat)
ft <- display(
  ft, col_key = "col", pattern = "# {{mylink}}",
  formatters = list(mylink ~ hyperlinked_text(href, col) )
)
ft

0
投票

`

dat <- data.frame(
    col = "entrez", 
    href = "https://www.ncbi.nlm.nih.gov/gene?cmd=Retrieve&dopt=full_report&list_uids=6850", 
    stringsAsFactors = FALSE)

ft <- flextable(dat)
ft <- display(
    ft, col_key = "col", pattern = "# {{mylink}}",
    formatters = list(mylink ~ hyperlink_text(href, col) )
)
ft # works fine

doc <- read_pptx() %>% 
    add_slide(layout = 'Title and Content', 'Office Theme') %>% 
    ph_with_flextable(ft) # error

doc_parse_raw中的错误(x,encoding = encoding,base_url = base_url,as_html = as_html,:EntityRef:expecting';'[23]

重复:

dat <- data.frame(
    col = "entrez", href = URLencode("https://www.ncbi.nlm.nih.gov/gene?cmd=Retrieve&dopt=full_report&list_uids=6850", reserved = TRUE),
    stringsAsFactors = FALSE)

ft <- flextable(dat)
ft <- display(
    ft, col_key = "col", pattern = "# {{mylink}}",
    formatters = list(mylink ~ hyperlink_text(href, col) )
)
ft # clicking the link in rstudio fails

doc <- read_pptx() %>% 
    add_slide(layout = 'Title and Content', 'Office Theme') %>% 
    ph_with_flextable(ft) # fine, no error message, but error message when opening pp file
© www.soinside.com 2019 - 2024. All rights reserved.