# writeNamedRegion-methods

0th

Percentile

##### Writing named regions to a workbook

Writes named regions to a '>workbook.

Keywords
methods, IO
##### Usage
# S4 method for workbook,ANY
writeNamedRegion(object,data,name,header,rownames)
##### Arguments
object

The '>workbook to use

data

Data to write

name

Name of the named region to write to

Specifies if the column names should be written. The default is TRUE.

rownames

Name (character) of column to use for the row names of the provided data object. If specified, the row names of the data object (data.frame) will be included as an additional column with the specified name. If rownames = NULL (default), no row names will be included. May also be a list in case multiple data objects are written in one call (see below).

##### Details

Writes data to the named region specified by name. Note that data is assumed to be a data.frame and is coerced to one if this is not already the case. The argument header specifies if the column names should be written. Note also that the arguments are vectorized and as such multiple named regions can be written with one call. In this case data is assumed to be a list of data objects (data.frame's).

##### Note

Named regions are automatically redefined to the area occupied by the written cells. This guarantees that the complete set of data can be re-read using readNamedRegion. Also, this allows the named region just to be defined as the top left cell to be written to. There is no need to know the exact size of the data in advance. When writing data to Excel, writeNamedRegion further applies cell styles to the cells as defined by the '>workbook's "style action" (see setStyleAction).

##### References

What are named regions/ranges? http://www.officearticles.com/excel/named_ranges_in_microsoft_excel.htm How to create named regions/ranges? http://www.youtube.com/watch?v=iAE9a0uRtpM

'>workbook, writeWorksheet, appendNamedRegion, appendWorksheet, readNamedRegion, readWorksheet, writeNamedRegionToFile

##### Aliases
• writeNamedRegion
• writeNamedRegion-methods
• writeNamedRegion,workbook-method
• writeNamedRegion,workbook,ANY-method
##### Examples
# NOT RUN {
# Load workbook (create if not existing)
wb <- loadWorkbook("writeNamedRegion.xlsx", create = TRUE)

# Create a worksheet named 'mtcars'
createSheet(wb, name = "mtcars")

# Create a named region called 'mtcars' on the sheet called 'mtcars'
createName(wb, name = "mtcars", formula = "mtcars!$A$1")

# Write built-in data set 'mtcars' to the above defined named region