Learn R Programming

excel.link (version 0.9.13)

xl.write: Methods for writing data to Excel sheet

Description

Methods for writing data to Excel sheet

Usage

xl.write(r.obj, xl.rng, na = "", ...)

# S3 method for current.graphics xl.write(r.obj, xl.rng, na = "", delete.file = FALSE, ...)

# S3 method for list xl.write(r.obj, xl.rng, na = "", ...)

# S3 method for matrix xl.write(r.obj, xl.rng, na = "", row.names = TRUE, col.names = TRUE, ...)

# S3 method for data.frame xl.write(r.obj, xl.rng, na = "", row.names = TRUE, col.names = TRUE, ...)

# S3 method for default xl.write(r.obj, xl.rng, na = "", row.names = TRUE, ...)

Value

c(rows,columns) Invisibly returns rows and columns number ocuppied by r.obj on Excel sheet.

Arguments

r.obj

R object

xl.rng

An object of class COMIDispatch (as used in RDCOMClient package) - reference to Excel range

na

character. NA representation in Excel. By default it is empty string

...

arguments for further processing

delete.file

a logical value indicating whether delete file with graphics after insertion in Excel

row.names

a logical value indicating whether the row names/vector names of r.obj should to be written along with r.obj

col.names

a logical value indicating whether the column names of r.obj should to be written along with r.obj

Details

xl.rng should be COM-reference to Excel range, not string. Method invisibly returns number of columns and rows occupied by r.obj on Excel sheet. It's useful for multiple objects writing to prevent their overlapping. It is more convenient to use xl object. xl.write aimed mostly for programming purposes, not for interactive usage.

See Also

xl, xlr, xlc, xlrc, current.graphics

Examples

Run this code
if (FALSE) {
xls = xl.get.excel()
xl.workbook.add()
rng = xls[["Activesheet"]]$Cells(1,1)
nxt = xl.write(iris,rng,row.names = TRUE,col.names = TRUE)
rng = rng$Offset(nxt[1] + 1,0)
nxt = xl.write(cars,rng,row.names = TRUE,col.names = TRUE)
rng = rng$Offset(nxt[1] + 1,0)
nxt = xl.write(as.data.frame(Titanic),rng,row.names = TRUE,col.names = TRUE)

data(iris)
data(cars)
data(Titanic)
xl.sheet.add()
rng = xls[["Activesheet"]]$Cells(1,1)
data.sets = list("Iris dataset",iris,
     "Cars dataset",cars,
     "Titanic dataset",as.data.frame(Titanic))
xl.write(data.sets,rng,row.names = TRUE,col.names = TRUE)

}

Run the code above in your browser using DataLab