xl.write: Methods for writing data to Excel sheet

View source: R/xl.write.R

xl.writeR Documentation

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 class 'current.graphics'
xl.write(r.obj, xl.rng, na = "", delete.file = FALSE, ...)

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

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

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

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

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.

Value

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

See Also

xl, xlr, xlc, xlrc, current.graphics

Examples

## Not run: 
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)


## End(Not run)

gdemin/excel.link documentation built on Feb. 10, 2024, 5 p.m.