Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ annotation zones, and content areas must be independently sized and never overla
| Type | R package (roxygen2, testthat) |
| License | AGPL-3 |
| R deps | `dplyr`, `ggplot2`, `grid`, `glue`, `rlang` |
| Suggests | `formatters`, `gt`, `rtables`, `testthat (>= 3.0.0)`, `withr`, `knitr`, `rmarkdown`, `tibble` |
| Suggests | `flextable`, `formatters`, `gt`, `rtables`, `testthat (>= 3.0.0)`, `withr`, `knitr`, `rmarkdown`, `tibble` |
| Namespace | All helpers unexported except `export_tfl`, `export_tfl_page`, `tfl_table`, `tfl_colspec` |

---
Expand Down Expand Up @@ -308,6 +308,12 @@ writetfl/
│ │ rtables_to_pagelist(),
│ │ .extract_rtables_annotations(),
│ │ .clean_rtables(), .rtables_to_grob()
│ ├── flextable.R ← export_tfl.flextable(),
│ │ flextable_to_pagelist(),
│ │ .extract_flextable_annotations(),
│ │ .clean_flextable(),
│ │ .flextable_to_grob(),
│ │ .paginate_flextable()
│ ├── reexports.R ← re-exports unit, gpar from grid
│ ├── table_columns.R ← resolve_col_specs(), compute_col_widths(),
│ │ paginate_cols()
Expand All @@ -333,6 +339,7 @@ writetfl/
│ ├── test-ggtibble.R
│ ├── test-gt.R
│ ├── test-rtables.R
│ ├── test-flextable.R
│ └── test-integration.R
├── vignettes/
│ ├── writetfl.Rmd
Expand All @@ -341,7 +348,8 @@ writetfl/
│ ├── v03-tfl_table_styling.Rmd
│ ├── v04-troubleshooting.Rmd
│ ├── v05-gt_tables.Rmd
│ └── v06-rtables.Rmd
│ ├── v06-rtables.Rmd
│ └── v07-flextable.Rmd
└── design/
├── DESIGN.md
├── ARCHITECTURE.md
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Imports:
glue,
rlang
Suggests:
flextable,
formatters,
ggtibble,
gt,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
S3method(drawDetails,tfl_table_grob)
S3method(export_tfl,VTableTree)
S3method(export_tfl,default)
S3method(export_tfl,flextable)
S3method(export_tfl,ggtibble)
S3method(export_tfl,gt_tbl)
S3method(export_tfl,list)
Expand Down
19 changes: 18 additions & 1 deletion R/export_tfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
#' `textGrob`. Pagination uses rtables' built-in `paginate_table()`.
#' A list of `VTableTree` objects produces one page (or more, with
#' pagination) per table.
#'
#' When `x` is a `flextable` object (from the \pkg{flextable} package),
#' the caption (from [flextable::set_caption()]) is extracted as the
#' caption, and footer rows (from [flextable::footnote()] or
#' [flextable::add_footer_lines()]) are extracted as the footnote. The
#' table is rendered via [flextable::gen_grob()]. A list of `flextable`
#' objects produces one page (or more, with pagination) per table.
#' @param file Path to the output PDF file. Must be a single character string
#' ending in `".pdf"`. Not required when `preview` is not `FALSE`.
#' @param pg_width Page width in inches.
Expand Down Expand Up @@ -173,7 +180,17 @@ export_tfl.list <- function(
pages <- unlist(lapply(x, rtables_to_pagelist, pg_width, pg_height,
dots, page_num), recursive = FALSE)
} else {
pages <- coerce_x_to_pagelist(x)
# Check if this is a list of flextable objects
all_flextable <- length(x) > 0L &&
all(vapply(x, inherits, logical(1L), "flextable"))
if (all_flextable) {
rlang::check_installed("flextable",
reason = "to export flextable tables")
pages <- unlist(lapply(x, flextable_to_pagelist, pg_width, pg_height,
dots, page_num), recursive = FALSE)
} else {
pages <- coerce_x_to_pagelist(x)
}
}
}
.export_tfl_pages(pages, file, pg_width, pg_height, page_num, preview, dots)
Expand Down
Loading
Loading