Learn R Programming

flexlsx

The primary objective of flexlsx is to offer an effortless interface for exporting flextable objects directly to Microsoft Excel. Building upon the robust foundation provided by openxlsx2 and flextable, flexlsx ensures compatibility, precision, and efficiency when working with both trivial and complex tables.

Installation

You can install the development version of flexlsx like so:

# install.packages("remotes")
remotes::install_github("pteridin/flexlsx")

Or install the CRAN release like so:

install.packages("flexlsx")

Example

This is a basic example which shows you how to solve a common problem:

library(flexlsx)

# Create a flextable and an openxlsx2 workbook
ft <- flextable::as_flextable(table(mtcars[,1:2]))
wb <- openxlsx2::wb_workbook()$add_worksheet("mtcars")

# add the flextable ft to the workbook, sheet "mtcars"
# offset the table to cell 'C2'
wb <- wb_add_flextable(wb, "mtcars", ft, dims = "C2")

# save the workbook to a temporary xlsx file
tmpfile <- tempfile(fileext = ".xlsx")
wb$save(tmpfile)

Copy Link

Version

Install

install.packages('flexlsx')

Monthly Downloads

270

Version

0.3.5

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Tobias Heidler

Last Published

April 25th, 2025

Functions in flexlsx (0.3.5)

wb_apply_border

Applies the border styles
wb_apply_content

Applies the content
wb_add_caption

Adds a caption to an excel file
wb_change_cell_width

Changes the cell width
wb_apply_text_styles

Applies the text styles
wb_change_row_height

Changes the row height
handle_null_border

Where there is no border return NULL
flexlsx-package

flexlsx: Exporting 'flextable' to 'xlsx' Files
merge_resolve_type

Determine problematic merges
ft_to_xlsx_border

Determines the border style
ftpart_to_style_tibble

Converts a flextable-part to a tibble styles
prepare_color

Prepares the color for content style
get_dim_rowwise

Groups each column with same style each row
get_dim_ranges

Retrieves dims of same style rows within same column
get_dim_colwise

Groups each row with same style each column
ft_to_style_tibble

Converts a flextable to a tibble with style information
wb_apply_merge

Merges cells
style_to_hash

Retrieves hashed style information
wb_add_flextable

Adds a flextable to an openxlsx2 workbook sheet
wb_apply_cell_styles

Applies the cell styles