Description Usage Arguments Value Examples
Write a XLSX file from a series of sheets, allowing inclusion of images.
1 2 | hwriteXLSX(file, worksheet, images = NULL, passwords = NULL,
overwrite = FALSE)
|
file |
name of the xlsx file to be written |
worksheet |
a sheet such as one created by |
images |
a named list defining the images to be included in the worksheet; see vignette and examples |
passwords |
a named list defining the passwords for the sheets |
overwrite |
logical, whether to overwrite the output file if it already exists |
No returned value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | sheet1 <- createSheet(iris, "iris")
sheet2 <- createSheet(mtcars, "mtcars")
worksheet <- c(sheet1, sheet2)
hwriteXLSX("xlsx.xlsx", worksheet)
# protect one sheet
hwriteXLSX("xlsx.xlsx", worksheet, passwords = list(iris="pwd"))
# include some images
image1File <- system.file("images", "Lissajous.png", package="hwriteXLSX")
image2File <- system.file("images", "power.png", package="hwriteXLSX")
image3File <- system.file("images", "timeseries.png", package="hwriteXLSX")
image1 <- list(file=image1File, left=6, top=2, width=400, height=400)
image2 <- list(file=image2File, left=6, top=23, width=500, height=400)
image3 <- list(file=image3File, left=13, top=2, width=500, height=400)
images <- list(iris = list(image1, image2), mtcars = list(image3))
hwriteXLSX("xlsx.xlsx", worksheet, images, overwrite = TRUE)
# colors example
colorMatrix <- matrix(grDevices::colours(), ncol=9)
f <- function(i, j){
cell(j, i, value = colorMatrix[i,j], color = colorMatrix[i,j], bold=TRUE)
}
sheet <- list(Colors = do.call(Vectorize(f), expand.grid(i=1:73, j=1:9)))
hwriteXLSX("colors.xlsx", sheet)
# Write a XLSX file from a list of lists
dat <-
list(
A = list(1, 2, 3),
B = list(NULL, "a", 1000),
C = list(NA, "b")
)
attr(dat$B[[2]], "color") <- "red"
attr(dat$B[[2]], "comment") <- "this cell is red"
attr(dat$C[[1]], "comment") <- "this cell is empty"
sheet <- createSheet(dat, "Sheet1")
hwriteXLSX("xlsx.xlsx", sheet, overwrite = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.