davidgohel / flextable

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

Images as column headers #568

Closed cataclysmic closed 1 year ago

cataclysmic commented 1 year ago

Hey maintainers,

I couldn't find a way to replace column headers with images/icons. It'd be great i you could implement this feature. Or add it to the documentation if already possible.

Thx in advance.

davidgohel commented 1 year ago

library(flextable)
img.file <- file.path( R.home("doc"),
                       "html", "logo.jpg" )

as_flextable(iris) |> 
  append_chunks(part = "header", as_image(src = img.file),
                j = 2:3, i = 1)
Capture d’écran 2023-09-03 à 12 15 25

Below an example. I can add a specific section to doc but that's hard to illustrate all questions. The links below shows how it works. A flextable has parts, each part can be modify with mk_par() or append_chunk(), a chunk can be an image.

https://ardata-fr.github.io/flextable-book/cell-content.html#function-mk_par

https://ardata-fr.github.io/flextable-book/cell-content.html#append-or-prepend-content

https://ardata-fr.github.io/flextable-book/cell-content.html#images

https://ardata-fr.github.io/flextable-book/table-design.html#table-parts

cataclysmic commented 1 year ago

Sorry for the fuzz. Thank you so much.

github-actions[bot] commented 8 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.