createSheet: Create a sheet

Description Usage Arguments Value See Also Examples

Description

Create a sheet from an appropriate data input.

Usage

1
createSheet(dat, sheetname)

Arguments

dat

appropriate data input (see examples and vignette)

sheetname

name of the sheet

Value

A named list containing one element: the list of cells.

See Also

hwriteXLSX

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Create a sheet from a dataframe
sheet <- createSheet(mtcars[1:2, 1:2], "Sheet1")
# write to xlsx.xlsx:
hwriteXLSX(file="xlsx.xlsx", worksheet=sheet)
# Create a sheet 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)

stla/hwriteXLSX documentation built on May 7, 2019, 10:40 a.m.