Title: | Exporting 'flextable' to 'xlsx' Files |
---|---|
Description: | Exports 'flextable' objects to 'xlsx' files, utilizing functionalities provided by 'flextable' and 'openxlsx2'. |
Authors: | Tobias Heidler [aut, cre, cph] |
Maintainer: | Tobias Heidler <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-11-14 06:00:42 UTC |
Source: | https://github.com/pteridin/flexlsx |
ft_to_style_tibble( ft, offset_rows = 0L, offset_cols = 0L, offset_caption_rows = 0L )
ft_to_style_tibble( ft, offset_rows = 0L, offset_cols = 0L, offset_caption_rows = 0L )
ft |
|
offset_rows |
offsets the start-row |
offset_cols |
offsets the start-columns |
offset_caption_rows |
number of rows to offset the caption by |
a tibble
ft_to_xlsx_border_width(border_width)
ft_to_xlsx_border_width(border_width)
border_width |
a numeric vector determining the border-width |
a factor of xlsx border styles
ftpart_to_style_tibble(ft_part, part = c("header", "body", "footer"))
ftpart_to_style_tibble(ft_part, part = c("header", "body", "footer"))
ft_part |
the part of the flextable to extract the style from |
part |
the name of the part |
a tibble
get_dim_colwise(df_rows)
get_dim_colwise(df_rows)
df_rows |
tibble of row-wise aggregates style |
tibble of column-wise aggregates style
get_dim_ranges(df_x)
get_dim_ranges(df_x)
df_x |
styling information incl. col_id & row_id |
merged styles as a tibble
get_dim_rowwise(df_x, df_style_hashed)
get_dim_rowwise(df_x, df_style_hashed)
df_x |
styling information incl. col_id & row_id |
df_style_hashed |
tibble of hashed style information |
tibble of row-wise aggregates style information
handle_null_border(border_width)
handle_null_border(border_width)
border_width |
a numeric vector determining the border-width |
border_width or NULL
Converts a color name to the hexadecimal RGB-value Removes "transparent" color
prepare_color(color_name)
prepare_color(color_name)
color_name |
The name of the color |
The hexadecimal RGB-value
Converts each style to an individual integer hash for easy comparison and aggregation.
style_to_hash(df_x)
style_to_hash(df_x)
df_x |
styling information incl. col_id & row_id |
hashed style information as a tibble
wb_add_flextable( wb, sheet, ft, start_col = 1, start_row = 1, offset_caption_rows = 0L, dims = NULL )
wb_add_flextable( wb, sheet, ft, start_col = 1, start_row = 1, offset_caption_rows = 0L, dims = NULL )
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" |
an openxlsx2 workbook
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) }
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) }
wb_apply_border(wb, sheet, df_style)
wb_apply_border(wb, sheet, df_style)
wb |
the workbook |
sheet |
the sheet of the workbook |
df_style |
the styling tibble from ft_to_style_tibble |
wb_apply_cell_styles(wb, sheet, df_style)
wb_apply_cell_styles(wb, sheet, df_style)
wb |
the workbook |
sheet |
the sheet of the workbook |
df_style |
the styling tibble from ft_to_style_tibble |
wb_apply_content(wb, sheet, df_style)
wb_apply_content(wb, sheet, df_style)
wb |
the workbook |
sheet |
the sheet of the workbook |
df_style |
the styling tibble from ft_to_style_tibble |
wb_apply_merge(wb, sheet, df_style)
wb_apply_merge(wb, sheet, df_style)
wb |
the workbook |
sheet |
the sheet of the workbook |
df_style |
the styling tibble from ft_to_style_tibble |
df_style tibble
wb_apply_text_styles(wb, sheet, df_style)
wb_apply_text_styles(wb, sheet, df_style)
wb |
the workbook |
sheet |
the sheet of the workbook |
df_style |
the styling tibble from ft_to_style_tibble |
Changes the cell width
wb_change_cell_width(wb, sheet, ft, offset_cols)
wb_change_cell_width(wb, sheet, ft, offset_cols)
wb |
an openxlsx2 workbook |
sheet |
an openxlsx2 workbook sheet |
ft |
a flextable |
offset_cols |
zero-based column offset |
Changes the row height
wb_change_row_height(wb, sheet, df_style)
wb_change_row_height(wb, sheet, df_style)
wb |
an openxlsx2 workbook |
sheet |
an openxlsx2 workbook sheet |
df_style |
the styling tibble from ft_to_style_tibble |