davidgohel / flextable

table farming
https://ardata-fr.github.io/flextable-book/
554 stars 79 forks source link

The border style of a cell is not taken into account when exporting to PPT with officer. #598

Closed dominiqueemmanuel closed 8 months ago

dominiqueemmanuel commented 8 months ago

I have simple flextable with a border (with fp_par) :

library(flextable)
library(officer)
d <- data.frame(x=1:2,y=1:2)

myft <- flextable(d) %>% style(i=1,j=1,pr_p = fp_par(
  border =fp_border(color="red"))

)
print(myft)

It looks fine a Rstudio Viewer (the 1 is bordered with a red line) : image

But when I want to export in PPT,

my_pres <- read_pptx()
my_pres <- add_slide(my_pres,
                     layout = "Two Content", master = "Office Theme"
)
my_pres<-ph_with(my_pres,value=myft,location = ph_location_left())
print(my_pres, target = "test.pptx")

the border disappear : image

Is it a bug ?

davidgohel commented 8 months ago

Not really (I did not remember I implemented borders for paragraphs).

There is a dedicated function for your need:

library(flextable)
library(officer)
d <- data.frame(x=1:2,y=1:2)

myft <- flextable(d)
myft <- surround(myft, i = 1, j = 1, border = fp_border(color = "red"))
print(myft, preview = "pptx")
Capture d’écran 2024-01-18 à 19 34 11
github-actions[bot] commented 2 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.