davidgohel / flextable

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

hline and PDF #507

Closed davidgohel closed 1 year ago

davidgohel commented 1 year ago
library(tidyverse)
library(flextable)
zed <- data.frame(Location = c("Home", "Business", "Cell"), Previous = c(1, 2, 3), Current = c(4, 5, 6))
zedt <- zed %>%
  flextable(.) %>%
  theme_zebra(.) %>%
  add_header_lines(., values = paste("Recent changes ", Sys.Date(), sep = "")) %>%
  bg(., i = 1:2, bg = "transparent", part = "header") %>%
  hline(., i = 1:2, border = officer::fp_border(color = "black"), part = "header") %>%
  hline(., i = 1:2, j = 2, border = officer::fp_border(color = "black"), part = "body") %>%
  hline_bottom(., border = officer::fp_border(color = "black"), part = "body") %>%
  align(., i = 1, j = 1, align = "left", part = "header") %>%
  bold(., i = 1, j = 1, bold = FALSE, part = "header") %>%
  line_spacing(., space = 1, part = "all") |> 
  fix_border_issues()

print(zedt, preview = "pdf")

Originally posted by @scbrooks382 in https://github.com/davidgohel/flextable/discussions/505#discussioncomment-4842924

scbrooks382 commented 1 year ago

Thanks for the quick response. Unfortunately, for me, adding fix_border_issues() did not solve the problem.

davidgohel commented 1 year ago

Yes, this is a bug. we will fix it

davidgohel commented 1 year ago

thanks, it should be fixed now

scbrooks382 commented 1 year ago

Thank you. Unfortunately, after updating to the new flextable package, the error remains. Using the code initially posted above I get this

incorrect 2023-02-20 092510

whereas the desired output that I was previously able to generate with flextable is this (horizontal border line under second row):

correct 2023-02-20 092510

davidgohel commented 1 year ago

OK,

On my side, I get:

Capture d’écran 2023-02-20 à 15 45 38

How did you update? (please add sessionInfo() results)

scbrooks382 commented 1 year ago

Through RStudio, I installed flextable 0.8.5 then started a new session and ran the code both with and without the fix_border_issues call

sessionInfo() R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

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

other attached packages: [1] forcats_0.5.2 stringr_1.5.0 dplyr_1.0.10 purrr_1.0.1 readr_2.1.3 tidyr_1.3.0 tibble_3.1.8
[8] ggplot2_3.4.0 tidyverse_1.3.2 flextable_0.8.5

loaded via a namespace (and not attached): [1] httr_1.4.4 jsonlite_1.8.4 modelr_0.1.10 shiny_1.7.4 assertthat_0.2.1
[6] askpass_1.1 googlesheets4_1.0.1 cellranger_1.1.0 gdtools_0.3.0 pillar_1.8.1
[11] backports_1.4.1 glue_1.6.2 uuid_1.1-0 digest_0.6.31 promises_1.2.0.1
[16] rvest_1.0.3 colorspace_2.1-0 htmltools_0.5.4 httpuv_1.6.8 gfonts_0.2.0
[21] pkgconfig_2.0.3 httpcode_0.3.0 broom_1.0.3 haven_2.5.1 xtable_1.8-4
[26] scales_1.2.1 later_1.3.0 officer_0.5.2 tzdb_0.3.0 timechange_0.2.0
[31] openssl_2.0.5 googledrive_2.0.0 generics_0.1.3 ellipsis_0.3.2 cachem_1.0.6
[36] withr_2.5.0 cli_3.6.0 magrittr_2.0.3 crayon_1.5.2 readxl_1.4.1
[41] mime_0.12 memoise_2.0.1 evaluate_0.20 fs_1.6.0 fansi_1.0.4
[46] xml2_1.3.3 tools_4.2.2 data.table_1.14.6 hms_1.1.2 gargle_1.2.1
[51] diffdf_1.0.4 lifecycle_1.0.3 munsell_0.5.0 reprex_2.0.2 zip_2.2.2
[56] compiler_4.2.2 tinytex_0.43 systemfonts_1.0.4 rlang_1.0.6 grid_4.2.2
[61] rstudioapi_0.14 base64enc_0.1-3 rmarkdown_2.20 gtable_0.3.1 DBI_1.1.3
[66] curl_5.0.0 R6_2.5.1 lubridate_1.9.1 knitr_1.42 fastmap_1.1.0
[71] utf8_1.2.2 stringi_1.7.12 crul_1.3 Rcpp_1.0.10 vctrs_0.5.2
[76] dbplyr_2.3.0 tidyselect_1.2.0 xfun_0.36

davidgohel commented 1 year ago

use remotes::install_github("davidgohel/flextable"), the update is on github

scbrooks382 commented 1 year ago

Yes! it seems to be working now. Thanks for the patience and help

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