excel.link (version 0.9.9)

xl: Data exchange with running Microsoft Excel instance.

Description

xl, xlc, xlr, xlrc objects are already defined in the package. It doesn't need to create or init them. Just after attaching package one can write something like this: xl[a1] = "Hello, world!" and this text should appears in A1 cell on active sheet of active Excel workbook. xl(*)n family of functions creates new worksheet for output. You can provide sheet name and position via xl.sheet.name/before.

Usage

# S3 method for xl
[(x, str.rng, drop = !(has.rownames(x) | has.colnames(x)), na = "", ...)

# S3 method for xl [[(x, str.rng, drop = !(has.rownames(x) | has.colnames(x)), na = "", ...)

# S3 method for xl $(x, str.rng)

# S3 method for xl [[(x, str.rng, na = "", ...) <- value

# S3 method for xl $(x, str.rng) <- value

# S3 method for xl [(x, str.rng, na = "", ...) <- value

# S3 method for xln [[(x, str.rng, na = "", xl.sheet.name = NULL, before = NULL, ...) <- value

# S3 method for xln $(x, str.rng) <- value

# S3 method for xln [(x, str.rng, na = "", xl.sheet.name = NULL, before = NULL, ...) <- value

xl.selection(drop = TRUE, na = "", row.names = FALSE, col.names = FALSE, ...)

Arguments

x

One of xl, xlc, xlr, xlrc objects. xl - read/write with/without column and row names, "r" - with rownames, "c" - with colnames

str.rng

character Excel range. For single bracket operations it can be without quotes in almost all cases.

drop

logical. If TRUE the result is coerced to the lowest possible dimension. By default dimensions will be dropped if there are no columns and rows names.

na

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

...

additional parameters. Not yet used.

value

suitable replacement value. It will be recycled to fill excel range only if it is object of length 1. In other cases size of excel range is ignored - all data will be placed in Excel sheet starting from top-left cell of submitted range.

xl.sheet.name

character. sheet name in active workbook (for xl(*)n).

before

character/numeric. sheet name or sheet number in active workbook before which new sheet will be added (for xl(*)n).

row.names

logical value indicating whether the Excel range contains the row names as its first column.

col.names

logical value indicating whether the Excel range contains the column names as its first row.

Value

Returns appropriate dataset from Excel.

Details

xl object represents Microsoft Excel application. For convenient interactive usage arguments can be given without quotes in most cases (e. g. xl[a1] = 5 or xl[u2:u85] = "Hi" or xl[MyNamedRange] = 42, but xl["Sheet1!A1"] = 42). When it used in your own functions or you need to use variable as argument it is recommended apply double brackets notation: xl[["a1"]] = 5 or xl[["u2:u85"]] = "Hi" or xl[["MyNamedRange"]] = 42. Difference between xl, xlc, xlrc and xlr is xl ignore row and column names, xlc suppose read and write to Excel with column names, xlrc - with column and row names and so on. There is argument drop which is TRUE by default for xl and FALSE by default for other options. xl.selection returns data.frame with data from current selection in Excel. All these functions never coerce characters to factors

See Also

cr, xl.current.region,

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
data(iris)
rownames(iris) = as.character(rownames(iris))
iris$Species = as.character(iris$Species)
xl.workbook.add()
xlrc$a1 = iris
xl.iris = xl.current.region("a1",row.names=TRUE,col.names=TRUE)
identical(xl.iris,iris)

xl.sheet.add("Datasets examples")
data.sets = list("Iris dataset",iris,"Cars dataset",cars,"Titanic dataset",as.data.frame(Titanic))
xlrc[a1] = data.sets

# }

Run the code above in your browser using DataCamp Workspace