Title: | Export Data Frames to Excel 'xlsx' Format |
---|---|
Description: | Zero-dependency data frame to xlsx exporter based on 'libxlsxwriter' <https://libxlsxwriter.github.io>. Fast and no Java or Excel required. |
Authors: | Jeroen Ooms [aut, cre] , John McNamara [cph] (Author of libxlsxwriter (see AUTHORS and COPYRIGHT files for details)) |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 1.5.1 |
Built: | 2024-11-04 06:23:00 UTC |
Source: | CRAN |
Writes a data frame to an xlsx file. To create an xlsx with (multiple) named
sheets, simply set x
to a named list of data frames.
write_xlsx( x, path = tempfile(fileext = ".xlsx"), col_names = TRUE, format_headers = TRUE, use_zip64 = FALSE )
write_xlsx( x, path = tempfile(fileext = ".xlsx"), col_names = TRUE, format_headers = TRUE, use_zip64 = FALSE )
x |
data frame or named list of data frames that will be sheets in the xlsx |
path |
a file name to write to |
col_names |
write column names at the top of the file? |
format_headers |
make the |
use_zip64 |
use zip64 to enable support for 4GB+ xlsx files. Not all platforms can read this. |
Currently supports strings, numbers, booleans and dates. Formatting options may be added in future versions.
# Roundtrip example with single excel sheet named 'mysheet' tmp <- write_xlsx(list(mysheet = iris)) readxl::read_xlsx(tmp)
# Roundtrip example with single excel sheet named 'mysheet' tmp <- write_xlsx(list(mysheet = iris)) readxl::read_xlsx(tmp)
Create special column types to write to a spreadsheet
xl_formula(x) xl_hyperlink(url, name = NULL)
xl_formula(x) xl_hyperlink(url, name = NULL)
x |
character vector to be interpreted as formula |
url |
character vector of URLs |
name |
character vector of friendly names |
df <- data.frame( name = c("UCLA", "Berkeley", "Jeroen"), founded = c(1919, 1868, 2030), website = xl_hyperlink(c("http://www.ucla.edu", "http://www.berkeley.edu", NA), "homepage") ) df$age <- xl_formula('=(YEAR(TODAY()) - INDIRECT("B" & ROW()))') write_xlsx(df, 'universities.xlsx') # cleanup unlink('universities.xlsx')
df <- data.frame( name = c("UCLA", "Berkeley", "Jeroen"), founded = c(1919, 1868, 2030), website = xl_hyperlink(c("http://www.ucla.edu", "http://www.berkeley.edu", NA), "homepage") ) df$age <- xl_formula('=(YEAR(TODAY()) - INDIRECT("B" & ROW()))') write_xlsx(df, 'universities.xlsx') # cleanup unlink('universities.xlsx')