flextable looks different in R viewer vs. in HTML

Does anyone know why flextables look different in the RStudio viewer vs. opening an HTML with the table?
Not sure why the inner table cell looks different.

library(dplyr)
library(flextable)
library(officer)

iris %>% head(n=4) %>% flextable() %>% 
  bg(bg = "#00557F", part = "header") %>%
  bold(part = "header") %>%
  color( color = "white", part = "header") %>%
  border_outer(border = big_border, part = "all" ) %>%
  border_inner_h( border = std_border, part = "all" ) %>%
  border_inner_v( border = std_border, part = "all" ) %>% 
  autofit() %>% save_as_html(path = 'ex.html')

Chrome vs. RStudio

The image in Chrome is on the Left and RStudio viewer is on the right.
I think the version in RStudio viewer looks correct, but Chrome does not. Not sure why.

HI @LionelD,
Looks like this is just an HTML rendering issue. If you zoom-in on the table in your browser you will see that the lines all become clearly the same width.

If this is a problem then maybe save the file as a high-resolution PNG file using save_as_image() and then use that.

p.s. Your original code post was missing the border definitions:

library(dplyr)
library(flextable)
library(officer)

big_border = fp_border(color="red", width = 3)
std_border = fp_border(color="blue", width = 1)

iris %>% head(n=4) %>% flextable() %>% 
  bg(bg = "#00557F", part = "header") %>%
  bold(part = "header") %>%
  color( color = "white", part = "header") %>%
  border_outer(border = big_border, part = "all" ) %>%
  border_inner_h( border = std_border, part = "all" ) %>%
  border_inner_v( border = std_border, part = "all" ) %>% 
  autofit() %>% 
  save_as_html(path = 'ex.html')

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.