Description Usage Arguments Author(s) References Examples
Add a table to an Excel worksheet
1 2 3 4 5 |
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") |
Alboukadel Kassambara <alboukadel.kassambara@gmail.com>
http://www.sthda.com
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.