davidgohel / flextable

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

Way to split wide tables into multiple pages. #583

Closed samueldepaul closed 6 months ago

samueldepaul commented 11 months ago

Hi! Thanks for the package and the work to keep it updated.

I've been using it for a while to generate tables in Word documents and the problem I keep running into, and for which I'm not able to find a solution is how to divide tables that are too wide for a landscape page in Word.

I know how to divide "tall" tables but can't do the same for wide ones. Is there a way to do it? If not, is it possible to add some parameter that enables me to do so?

Thanks a lot!!

davidgohel commented 10 months ago

Hi,

The thing is that the user solution is not clear to me. What does that means?

You want a function that create a list of tables? An identifier column must be repeated for each sub tables or there is no identifier column? Should these results be paginated also? There are many if-else to clear.

For now, it's quite easy to do it by yourself, only select a set of columns, create the corresponding table and add them to Word or PDF or HTML. You can check the widths with dim() or flextable_dim(). You can use a for loop to add the tables in a document (with officer or knitr).

Can you share a result so that we can see exactly what is asked?

davidgohel commented 6 months ago

Maybe I was thinking for some automatic solution while you were just waiting for a pointer to do it

library(tibble)
library(flextable)
x <- mtcars |> rownames_to_column()

z <- flextable(x) |> autofit()
z1 <- delete_columns(z, j = 8:12)
z2 <- delete_columns(z, j = 2:7)
github-actions[bot] commented 3 weeks 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.