The rapidxlsx package
provides high-throughput serialization of R data frames to Microsoft
Excel (.xlsx) workbooks. It utilizes a multi-threaded Rust
engine with zero-copy SEXP vector ingestion and parallel Deflate block
compression (Z_SYNC_FLUSH).
The primary function is write_xlsx(). It takes a
data.frame and an output file path:
library(rapidxlsx)
df <- data.frame(
id = 101:105,
name = c("Alice", "Bob", "Charlie", "David", "Eva"),
score = c(95.5, 88.0, 92.3, 76.4, 89.1),
active = c(TRUE, FALSE, TRUE, TRUE, FALSE),
group = factor(c("A", "B", "A", "C", "B")),
stringsAsFactors = FALSE
)
tmp <- tempfile(fileext = ".xlsx")
write_xlsx(df, tmp, sheet_name = "Participants")The function returns the path invisibly, enabling standard R piping
(|> or %>%):
Missing values (NA, NA_real_,
NA_integer_, NA_character_) are mapped to
empty OpenXML cells:
The compression_level argument accepts integers from 1
to 9 (default 1L):
1L: Fastest compression throughput (recommended for
large datasets exceeding 100,000 rows).6L or 9L: Higher compression ratio at the
expense of CPU time.