| Type: | Package | 
| Title: | Exporting 'flextable' to 'xlsx' Files | 
| Version: | 0.3.5 | 
| Description: | Exports 'flextable' objects to 'xlsx' files, utilizing functionalities provided by 'flextable' and 'openxlsx2'. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| Imports: | dplyr (≥ 1.1.1), grDevices, openxlsx2 (≥ 1.0.0), purrr, Rcpp, rlang, stringi, tibble, tidyr (≥ 1.0.0) | 
| Suggests: | covr, gtsummary, flextable (≥ 0.9.5), testthat (≥ 3.0.0), officer | 
| Depends: | R (≥ 4.1.0) | 
| RoxygenNote: | 7.3.2 | 
| Config/testthat/edition: | 3 | 
| URL: | https://github.com/pteridin/flexlsx | 
| BugReports: | https://github.com/pteridin/flexlsx/issues | 
| LinkingTo: | Rcpp | 
| NeedsCompilation: | yes | 
| Packaged: | 2025-04-25 12:37:33 UTC; tobias | 
| Author: | Tobias Heidler | 
| Maintainer: | Tobias Heidler <flexlsx@heidler.ovh> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-04-25 23:20:12 UTC | 
flexlsx: Exporting 'flextable' to 'xlsx' Files
Description
 
Exports 'flextable' objects to 'xlsx' files, utilizing functionalities provided by 'flextable' and 'openxlsx2'.
Author(s)
Maintainer: Tobias Heidler tobias.heidler@googlemail.com (ORCID) [copyright holder]
See Also
Useful links:
Converts a flextable to a tibble with style information
Description
Usage
ft_to_style_tibble(
  ft,
  offset_rows = 0L,
  offset_cols = 0L,
  offset_caption_rows = 0L
)
Arguments
| ft | |
| offset_rows | offsets the start-row | 
| offset_cols | offsets the start-columns | 
| offset_caption_rows | number of rows to offset the caption by | 
Value
a tibble
Determines the border style
Description
Usage
ft_to_xlsx_border(border_color, border_width, border_style)
Arguments
| border_color | the color of the border | 
| border_width | a numeric vector determining the border-width | 
| border_style | the flextable style name of the border | 
Details
openxlsx2/Excel does handle borders differently than flextable. This function maps the flextable border styles to the Excel border styles.
Value
a factor of xlsx border styles
Converts a flextable-part to a tibble styles
Description
Usage
ftpart_to_style_tibble(ft_part, part = c("header", "body", "footer"))
Arguments
| ft_part | the part of the flextable to extract the style from | 
| part | the name of the part | 
Value
a tibble
Groups each row with same style each column
Description
Usage
get_dim_colwise(df_rows)
Arguments
| df_rows | tibble of row-wise aggregates style | 
Value
tibble of column-wise aggregates style
Retrieves dims of same style rows within same column
Description
Usage
get_dim_ranges(df_x)
Arguments
| df_x | styling information incl. col_id & row_id | 
Value
merged styles as a tibble
Groups each column with same style each row
Description
Usage
get_dim_rowwise(df_x, df_style_hashed)
Arguments
| df_x | styling information incl. col_id & row_id | 
| df_style_hashed | tibble of hashed style information | 
Value
tibble of row-wise aggregates style information
Where there is no border return NULL
Description
Usage
handle_null_border(border_style)
Arguments
| border_style | the openxlsx2 style of the border | 
Value
border_style or NULL
Determine problematic merges
Description
Determine problematic merges
Usage
merge_resolve_type(df_to_merge)
Arguments
| df_to_merge | The data.frame containing information about the cells to merge | 
Value
df_to_merge is extended by is_encapsulated and is_need_resolve
Prepares the color for content style
Description
Converts a color name to the hexadecimal RGB-value Removes "transparent" color
Usage
prepare_color(color_name)
Arguments
| color_name | The name of the color | 
Value
The hexadecimal RGB-value
Retrieves hashed style information
Description
Converts each style to an individual integer hash for easy comparison and aggregation.
Usage
style_to_hash(df_x)
Arguments
| df_x | styling information incl. col_id & row_id | 
Value
hashed style information as a tibble
Adds a caption to an excel file
Description
Usage
wb_add_caption(
  wb,
  sheet,
  ft,
  offset_rows = offset_rows,
  offset_cols = offset_cols
)
Arguments
| wb | an openxlsx2 workbook | 
| sheet | an openxlsx2 workbook sheet | 
| ft | a flextable | 
| offset_rows | zero-based row offset | 
| offset_cols | zero-based column offset | 
Adds a flextable to an openxlsx2 workbook sheet
Description
Usage
wb_add_flextable(
  wb,
  sheet = openxlsx2::current_sheet(),
  ft,
  start_col = 1,
  start_row = 1,
  offset_caption_rows = 0L,
  dims = NULL
)
Arguments
| wb | an openxlsx2 workbook | 
| sheet | an openxlsx2 workbook sheet | 
| ft | a flextable | 
| start_col | a vector specifying the starting column to write to. | 
| start_row | a vector specifying the starting row to write to. | 
| offset_caption_rows | number of rows to offset the caption by | 
| dims | Spreadsheet dimensions that will determine start_col and start_row: "A1", "A1:B2", "A:B" | 
Value
an openxlsx2 workbook
Examples
if (requireNamespace("flextable", quietly = TRUE)) {
  # Create a flextable
  ft <- flextable::as_flextable(table(mtcars[, c("am", "cyl")]))
  # Create a workbook
  wb <- openxlsx2::wb_workbook()$add_worksheet("mtcars")
  # Add flextable to workbook
  wb <- wb_add_flextable(wb, "mtcars", ft)
  # Workbook can now be saved wb$save(),
  # opened wb$open() - or removed
  rm(wb)
}
Applies the border styles
Description
Usage
wb_apply_border(wb, sheet, df_style)
Arguments
| wb | the workbook | 
| sheet | the sheet of the workbook | 
| df_style | the styling tibble from ft_to_style_tibble | 
Applies the cell styles
Description
Usage
wb_apply_cell_styles(wb, sheet, df_style)
Arguments
| wb | the workbook | 
| sheet | the sheet of the workbook | 
| df_style | the styling tibble from ft_to_style_tibble | 
Applies the content
Description
Usage
wb_apply_content(wb, sheet, df_style)
Arguments
| wb | the workbook | 
| sheet | the sheet of the workbook | 
| df_style | the styling tibble from ft_to_style_tibble | 
Merges cells
Description
Usage
wb_apply_merge(wb, sheet, df_style)
Arguments
| wb | the workbook | 
| sheet | the sheet of the workbook | 
| df_style | the styling tibble from ft_to_style_tibble | 
Value
df_style tibble
Applies the text styles
Description
Usage
wb_apply_text_styles(wb, sheet, df_style)
Arguments
| wb | the workbook | 
| sheet | the sheet of the workbook | 
| df_style | the styling tibble from ft_to_style_tibble | 
Changes the cell width
Description
Changes the cell width
Usage
wb_change_cell_width(wb, sheet, ft, offset_cols)
Arguments
| wb | an openxlsx2 workbook | 
| sheet | an openxlsx2 workbook sheet | 
| ft | a flextable | 
| offset_cols | zero-based column offset | 
Changes the row height
Description
Changes the row height
Usage
wb_change_row_height(wb, sheet, df_style)
Arguments
| wb | an openxlsx2 workbook | 
| sheet | an openxlsx2 workbook sheet | 
| df_style | the styling tibble from ft_to_style_tibble |