davidgohel / flextable

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

cannot get row heights with columns with the largest text #558

Closed jic007 closed 1 year ago

jic007 commented 1 year ago

due to long text in some columns I couldn't use dim_pretty to get the heights. so I did a work around instead of using dim_pretty(part = "body") for the heights, I used dim() and skipped the first obseravation.

Issue is that I need to get the heights of the second column and couldn't find any where a way to do it

i tried to use df %>% flextable() %>%

FitFlextableToPage(colms = 1:6, width_s = c(2,9,3,3,2,4))  |> 

hrule(rule = "auto", part = "header") |> dim() 

but still I am getting .25 is there a way to get row height based on a column?

davidgohel commented 1 year ago

couldn't find any where a way to do it

when something is not documented, it means it is not a feature.

If you want to have a long text wrapped in a cell, flextable is not able to tell you what is the height. dim_pretty() can tell you what would be the width and height if displayed on one row, it managed \n in this calculation.

As indicated in the manual, dim() applied to a flextable returns widths and heights for each table columns and rows. Values are expressed in inches. It does not calculate anything, it returns the dimension that are set. So you are getting .25 because this is the value that is set.

is there a way to get row height based on a column?

No, I am not sure what is means, you probably mean get the row height based on a column width, padding, font size, etc and a long text wrapped into that width. The answer is no, there is no function like this in flextable

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