davidgohel / flextable

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

na_str =" " needed to stop ppt blank cells having ppt default text size #597

Closed JoHoGH closed 8 months ago

JoHoGH commented 9 months ago
 library(dplyr)
 library(flextable)
  # set_flextable_defaults(na_str =" " )  # Run first with this commented, then uncomment and run again
 print(iris[1:25,] %>%
         mutate(Sepal.Length = replace(Sepal.Length, seq(1,25,2),NA))%>%  
         flextable() %>% 
         theme_box() %>%  
         padding(padding.top = 0, padding.bottom = 0, part = "all") %>% 
         height(height = .5, unit = "cm") %>%
         hrule(rule="exact", part = "all"),
       preview = "pptx")

When trying to set dimensions of a table to fit on a PowerPoint slide, I find that empty/NA cells font size gets reset to the default PowerPoint text size. My workaround for this is to set default na_str to a space, set_flextable_defaults(na_str =" ") Happy to carry on using this workaround if there is no other fix.


> sessionInfo()
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8    

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] flextable_0.9.4 dplyr_1.1.4    

loaded via a namespace (and not attached):
 [1] zip_2.3.0               Rcpp_1.0.11             fontBitstreamVera_0.1.1 pillar_1.9.0            compiler_4.2.3         
 [6] later_1.3.2             gfonts_0.2.0            tools_4.2.3             uuid_1.1-1              digest_0.6.33          
[11] evaluate_0.23           jsonlite_1.8.8          lifecycle_1.0.4         tibble_3.2.1            pkgconfig_2.0.3        
[16] rlang_1.1.2             shiny_1.8.0             cli_3.6.1               rstudioapi_0.15.0       curl_5.2.0             
[21] crul_1.4.0              xfun_0.41               fontLiberation_0.1.0    fastmap_1.1.1           xml2_1.3.6             
[26] officer_0.6.3           knitr_1.45              askpass_1.2.0           systemfonts_1.0.5       gdtools_0.3.4          
[31] generics_0.1.3          vctrs_0.6.5             grid_4.2.3              tidyselect_1.2.0        glue_1.6.2             
[36] httpcode_0.3.0          data.table_1.14.10      R6_2.5.1                textshaping_0.3.7       fansi_1.0.5            
[41] rmarkdown_2.25          magrittr_2.0.3          fontquiver_0.2.1        ellipsis_0.3.2          promises_1.2.1         
[46] htmltools_0.5.7         mime_0.12               xtable_1.8-4            renv_0.15.5             httpuv_1.6.13          
[51] ragg_1.2.6              utf8_1.2.4              openssl_2.1.1           crayon_1.5.2       
JoHoGH commented 9 months ago

Sorry, I didn't look properly. This is like #153

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.