This package is a wrapper for openxlsx. It reads entire excel files with all their sheets into a list of data frames (one data frame for each sheet, one list of data frame for one excel file). For creating an excel file, put together all your data frames into a list and give them names for the sheet titles. The withNames() function helps during the input by making it possible to alternate name and data frame.

#devtools::load_all()
library(xlsx2dfs)
#> Loading required package: openxlsx
df1 <- data.frame(genes = c("gene1", "gene2"),
                  count = c(23,  50))
df2 <- data.frame(genes = c("gene3", "gene4"),
                  count = c(100, 500))
# write one data frame on one sheet
dfs2xlsx(withNames("first sheet", df1), "../inst/extdata/test_one_df.xlsx")
#> Note: zip::zip() is deprecated, please use zip::zipr() instead

# write more data frames into one file
dfs2xlsx(withNames("first data frame", df1,
                   "second data frame", df2), "../inst/extdata/test_two_dfs.xlsx")

# or create a data frame list with the desired names
# and print into xlsx file
df.list <- list(`first data frame`=df1,
                `second data frame`=df2)
# actually "withNames()" is superfluous ...
dfs2xlsx(df.list, "../inst/extdata/test_two_dfs1.xlsx")

# write one data frame into a file
dfs2xlsx(list(`one data frame`=df1),
         "../inst/extdata/one_df.xlsx")

# read-in excel file as a data frame list
dfs.list <- xlsx2dfs("../inst/extdata/test_two_dfs1.xlsx")