xlsx.addTable: Add a table to a worksheet

Description Usage Arguments Author(s) References Examples

View source: R/r2excel.r

Description

Add a table to an Excel worksheet

Usage

1
2
3
4
5
xlsx.addTable(wb, sheet, data, startRow = NULL, startCol = 2,
              col.names = TRUE, row.names = TRUE, columnWidth = 14,
              fontColor = "#FFFFFF", fontSize = 12,
              rownamesFill = "white", colnamesFill = "white",
              rowFill=c("white", "white"))

Arguments

wb

workbook object

sheet

sheet object

data

a data frame

startRow

a numeric value specifying the starting row

startCol

a numeric value specifying the starting column

col.names

a logical value indicating whether the column names of the data are to be written to the file. Default is TRUE

row.names

a logical value indicating whether the row names of the data are to be written to the file. Default is TRUE

columnWidth

a numeric value specifyingthe width of the column.

fontColor

the color of the text

fontSize

the size of the text

rownamesFill

the color for filling the cells containing row names

colnamesFill

the color for filling the cells containing row names

rowFill

a vector of two colors for filling odd and even rows. Default is c("white", "white")

Author(s)

Alboukadel Kassambara <alboukadel.kassambara@gmail.com>

References

http://www.sthda.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# create an Excel workbook. Both .xls and .xlsx file formats can be used.
wb <- createWorkbook(type="xlsx")
# Create a sheet in that workbook
sheet <- createSheet(wb, sheetName = "example1")

# add iris data using default settings
data(iris)
xlsx.addHeader(wb, sheet, value="Add iris table using default settings")
xlsx.addLineBreak(sheet, 1)
xlsx.addTable(wb, sheet, head(iris), startCol=2)
xlsx.addLineBreak(sheet, 2)
 
# Customized table
xlsx.addHeader(wb, sheet, value="Customized table")
xlsx.addLineBreak(sheet, 1)
xlsx.addTable(wb, sheet, data= head(iris),
              fontColor="darkblue", fontSize=14,
              rowFill=c("white", "lightblue")
)
xlsx.addLineBreak(sheet, 2)

# saving a workbook to an Excel file and write the file to the disk.
saveWorkbook(wb, "examples_add_table.xlsx")

kassambara/r2excel documentation built on May 20, 2019, 7:40 a.m.