Package 'flexlsx'

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

Help Index


Converts a flextable to a tibble with style information

Description

[Experimental]

Usage

ft_to_style_tibble(
  ft,
  offset_rows = 0L,
  offset_cols = 0L,
  offset_caption_rows = 0L
)

Arguments

ft

a flextable

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 width

Description

[Experimental]

Usage

ft_to_xlsx_border_width(border_width)

Arguments

border_width

a numeric vector determining the border-width

Value

a factor of xlsx border styles


Converts a flextable-part to a tibble styles

Description

[Experimental]

[Experimental]

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

[Experimental]

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

[Experimental]

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

[Experimental]

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

[Experimental]

Usage

handle_null_border(border_width)

Arguments

border_width

a numeric vector determining the border-width

Value

border_width or NULL


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

[Experimental]

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

[Experimental]

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

[Experimental]

Usage

wb_add_flextable(
  wb,
  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

[Experimental]

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

[Experimental]

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

[Experimental]

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

[Experimental]

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

[Experimental]

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