openxlsx/ 0000755 0001762 0000144 00000000000 14156124026 012133 5 ustar ligges users openxlsx/NAMESPACE 0000644 0001762 0000144 00000005075 14155631556 013373 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method("names<-",Workbook)
S3method(getNamedRegions,Workbook)
S3method(getNamedRegions,default)
S3method(names,Workbook)
S3method(read.xlsx,Workbook)
S3method(read.xlsx,default)
export("activeSheet<-")
export("sheetVisibility<-")
export("sheetVisible<-")
export("worksheetOrder<-")
export(activeSheet)
export(addCreator)
export(addFilter)
export(addStyle)
export(addWorksheet)
export(buildWorkbook)
export(cloneWorksheet)
export(col2int)
export(conditionalFormat)
export(conditionalFormatting)
export(convertFromExcelRef)
export(convertToDate)
export(convertToDateTime)
export(copyWorkbook)
export(createComment)
export(createNamedRegion)
export(createStyle)
export(createWorkbook)
export(dataValidation)
export(deleteData)
export(deleteNamedRegion)
export(freezePane)
export(getBaseFont)
export(getCellRefs)
export(getCreators)
export(getDateOrigin)
export(getNamedRegions)
export(getSheetNames)
export(getStyles)
export(getTables)
export(groupColumns)
export(groupRows)
export(insertImage)
export(insertPlot)
export(int2col)
export(loadWorkbook)
export(makeHyperlinkString)
export(mergeCells)
export(modifyBaseFont)
export(op.openxlsx)
export(openXL)
export(openxlsx_getOp)
export(openxlsx_setOp)
export(pageBreak)
export(pageSetup)
export(protectWorkbook)
export(protectWorksheet)
export(read.xlsx)
export(readWorkbook)
export(removeCellMerge)
export(removeColWidths)
export(removeComment)
export(removeFilter)
export(removeRowHeights)
export(removeTable)
export(removeWorksheet)
export(renameWorksheet)
export(replaceStyle)
export(saveWorkbook)
export(setColWidths)
export(setFooter)
export(setHeader)
export(setHeaderFooter)
export(setLastModifiedBy)
export(setRowHeights)
export(sheetVisibility)
export(sheetVisible)
export(sheets)
export(showGridLines)
export(temp_xlsx)
export(ungroupColumns)
export(ungroupRows)
export(worksheetOrder)
export(write.xlsx)
export(writeComment)
export(writeData)
export(writeDataTable)
export(writeFormula)
import(Rcpp)
import(methods)
import(stringi)
importFrom(grDevices,bmp)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colours)
importFrom(grDevices,dev.copy)
importFrom(grDevices,dev.list)
importFrom(grDevices,dev.off)
importFrom(grDevices,jpeg)
importFrom(grDevices,png)
importFrom(grDevices,rgb)
importFrom(grDevices,tiff)
importFrom(stats,pchisq)
importFrom(utils,download.file)
importFrom(utils,head)
importFrom(utils,menu)
importFrom(utils,unzip)
importFrom(zip,zipr)
useDynLib(openxlsx, .registration=TRUE)
openxlsx/LICENSE 0000644 0001762 0000144 00000000065 14155600363 013143 0 ustar ligges users YEAR: 2014-2021
COPYRIGHT HOLDER: openxlsx authors
openxlsx/README.md 0000644 0001762 0000144 00000003123 14155600363 013413 0 ustar ligges users [openxlsx](https://ycphs.github.io/openxlsx/)
========
[](https://app.codecov.io/gh/ycphs/openxlsx)
[](https://cran.r-project.org/package=openxlsx)
[](https://cran.r-project.org/package=openxlsx)

This [R](https://www.R-project.org/) package simplifies the creation of `.xlsx` files by providing
a high level interface to writing, styling and editing worksheets. Through the use of [`Rcpp`](https://CRAN.R-project.org/package=Rcpp), read/write times are comparable to the [`xlsx`](https://CRAN.R-project.org/package=xlsx) and
[`XLConnect`](https://CRAN.R-project.org/package=XLConnect) packages with the added benefit of removing the dependency on
Java.
## Installation
### Stable version
Current stable version is available on [CRAN](https://CRAN.R-project.org/) via
```R
install.packages("openxlsx", dependencies = TRUE)
```
### Development version
```R
install.packages(c("Rcpp", "remotes"), dependencies = TRUE)
remotes::install_github("ycphs/openxlsx")
```
## Bug/feature request
Please let me know which version of openxlsx you are using when posting bug reports.
```R
packageVersion("openxlsx")
```
## News
[Here](https://raw.githubusercontent.com/ycphs/openxlsx/master/NEWS.md).
openxlsx/man/ 0000755 0001762 0000144 00000000000 14155633372 012716 5 ustar ligges users openxlsx/man/protectWorkbook.Rd 0000644 0001762 0000144 00000002723 14155600363 016401 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{protectWorkbook}
\alias{protectWorkbook}
\title{Protect a workbook from modifications}
\usage{
protectWorkbook(
wb,
protect = TRUE,
password = NULL,
lockStructure = FALSE,
lockWindows = FALSE,
type = 1L
)
}
\arguments{
\item{wb}{A workbook object}
\item{protect}{Whether to protect or unprotect the sheet (default=TRUE)}
\item{password}{(optional) password required to unprotect the workbook}
\item{lockStructure}{Whether the workbook structure should be locked}
\item{lockWindows}{Whether the window position of the spreadsheet should be locked}
\item{type}{Lock type, default 1. From the xml documentation: 1 - Document is password protected. 2 - Document is recommended to be opened as read-only. 4 - Document is enforced to be opened as read-only. 8 - Document is locked for annotation.}
}
\description{
Protect or unprotect a workbook from modifications by the user in the graphical user interface. Replaces an existing protection.
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "S1")
protectWorkbook(wb, protect = TRUE, password = "Password", lockStructure = TRUE)
\dontrun{
saveWorkbook(wb, "WorkBook_Protection.xlsx", overwrite = TRUE)
}
# Remove the protection
protectWorkbook(wb, protect = FALSE)
\dontrun{
saveWorkbook(wb, "WorkBook_Protection_unprotected.xlsx", overwrite = TRUE)
}
}
\author{
Reinhold Kainhofer
}
openxlsx/man/replaceStyle.Rd 0000644 0001762 0000144 00000001716 14155600364 015641 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{replaceStyle}
\alias{replaceStyle}
\title{Replace an existing cell style}
\usage{
replaceStyle(wb, index, newStyle)
}
\arguments{
\item{wb}{A workbook object}
\item{index}{Index of style object to replace}
\item{newStyle}{A style to replace the existing style as position index}
}
\description{
Replace an existing cell style
Replace a style object
}
\examples{
## load a workbook
wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx"))
## create a new style and replace style 2
newStyle <- createStyle(fgFill = "#00FF00")
## replace style 2
getStyles(wb)[1:3] ## prints styles
replaceStyle(wb, 2, newStyle = newStyle)
## Save workbook
\dontrun{
saveWorkbook(wb, "replaceStyleExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=getStyles]{getStyles()}}
}
\author{
Alexander Walker
}
openxlsx/man/writeFormula.Rd 0000644 0001762 0000144 00000005502 14155600364 015662 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/writeData.R
\name{writeFormula}
\alias{writeFormula}
\title{Write a character vector as an Excel Formula}
\usage{
writeFormula(
wb,
sheet,
x,
startCol = 1,
startRow = 1,
array = FALSE,
xy = NULL
)
}
\arguments{
\item{wb}{A Workbook object containing a worksheet.}
\item{sheet}{The worksheet to write to. Can be the worksheet index or name.}
\item{x}{A character vector.}
\item{startCol}{A vector specifying the starting column to write to.}
\item{startRow}{A vector specifying the starting row to write to.}
\item{array}{A bool if the function written is of type array}
\item{xy}{An alternative to specifying \code{startCol} and
\code{startRow} individually. A vector of the form
\code{c(startCol, startRow)}.}
}
\description{
Write a a character vector containing Excel formula to a worksheet.
}
\details{
Currently only the english version of functions are supported. Please don't use the local translation.
The examples below show a small list of possible formulas:
\itemize{
\item{SUM(B2:B4)}
\item{AVERAGE(B2:B4)}
\item{MIN(B2:B4)}
\item{MAX(B2:B4)}
\item{...}
}
}
\examples{
## There are 3 ways to write a formula
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
writeData(wb, "Sheet 1", x = iris)
## SEE int2col() to convert int to Excel column label
## 1. - As a character vector using writeFormula
v <- c("SUM(A2:A151)", "AVERAGE(B2:B151)") ## skip header row
writeFormula(wb, sheet = 1, x = v, startCol = 10, startRow = 2)
writeFormula(wb, 1, x = "A2 + B2", startCol = 10, startRow = 10)
## 2. - As a data.frame column with class "formula" using writeData
df <- data.frame(
x = 1:3,
y = 1:3,
z = paste(paste0("A", 1:3 + 1L), paste0("B", 1:3 + 1L), sep = " + "),
z2 = sprintf("ADDRESS(1,\%s)", 1:3),
stringsAsFactors = FALSE
)
class(df$z) <- c(class(df$z), "formula")
class(df$z2) <- c(class(df$z2), "formula")
addWorksheet(wb, "Sheet 2")
writeData(wb, sheet = 2, x = df)
## 3. - As a vector with class "formula" using writeData
v2 <- c("SUM(A2:A4)", "AVERAGE(B2:B4)", "MEDIAN(C2:C4)")
class(v2) <- c(class(v2), "formula")
writeData(wb, sheet = 2, x = v2, startCol = 10, startRow = 2)
## Save workbook
\dontrun{
saveWorkbook(wb, "writeFormulaExample.xlsx", overwrite = TRUE)
}
## 4. - Writing internal hyperlinks
wb <- createWorkbook()
addWorksheet(wb, "Sheet1")
addWorksheet(wb, "Sheet2")
writeFormula(wb, "Sheet1", x = '=HYPERLINK("#Sheet2!B3", "Text to Display - Link to Sheet2")')
## Save workbook
\dontrun{
saveWorkbook(wb, "writeFormulaHyperlinkExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=writeData]{writeData()}} \code{\link[=makeHyperlinkString]{makeHyperlinkString()}}
}
\author{
Alexander Walker
}
openxlsx/man/getStyles.Rd 0000644 0001762 0000144 00000001017 14155600363 015161 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{getStyles}
\alias{getStyles}
\title{Returns a list of all styles in the workbook}
\usage{
getStyles(wb)
}
\arguments{
\item{wb}{A workbook object}
}
\description{
Returns list of style objects in the workbook
}
\examples{
## load a workbook
wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx"))
getStyles(wb)[1:3]
}
\seealso{
\code{\link[=replaceStyle]{replaceStyle()}}
}
openxlsx/man/activeSheet.Rd 0000644 0001762 0000144 00000001523 14155600363 015444 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{activeSheet}
\alias{activeSheet}
\alias{activeSheet<-}
\title{Get/set active sheet of the workbook}
\usage{
activeSheet(wb)
activeSheet(wb) <- value
}
\arguments{
\item{wb}{A workbook object}
\item{value}{index of the active sheet or name of the active sheet}
}
\value{
return the active sheet of the workbook
}
\description{
Get and set active sheet of the workbook
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, sheetName = "S1")
addWorksheet(wb, sheetName = "S2")
addWorksheet(wb, sheetName = "S3")
activeSheet(wb) # default value is the first sheet active
activeSheet(wb) <- 1 ## active sheet S1
activeSheet(wb)
activeSheet(wb) <- "S2" ## active sheet S2
activeSheet(wb)
}
\author{
Philipp Schauberger
}
openxlsx/man/addFilter.Rd 0000644 0001762 0000144 00000002167 14155600363 015103 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{addFilter}
\alias{addFilter}
\title{Add column filters}
\usage{
addFilter(wb, sheet, rows, cols)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{rows}{A row number.}
\item{cols}{columns to add filter to.}
}
\description{
Add excel column filters to a worksheet
}
\details{
adds filters to worksheet columns, same as filter parameters in writeData.
writeDataTable automatically adds filters to first row of a table.
NOTE Can only have a single filter per worksheet unless using tables.
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2")
addWorksheet(wb, "Sheet 3")
writeData(wb, 1, iris)
addFilter(wb, 1, row = 1, cols = 1:ncol(iris))
## Equivalently
writeData(wb, 2, x = iris, withFilter = TRUE)
## Similarly
writeDataTable(wb, 3, iris)
\dontrun{
saveWorkbook(wb, file = "addFilterExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=writeData]{writeData()}}
\code{\link[=addFilter]{addFilter()}}
}
openxlsx/man/protectWorksheet.Rd 0000644 0001762 0000144 00000005077 14155600363 016564 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{protectWorksheet}
\alias{protectWorksheet}
\title{Protect a worksheet from modifications}
\usage{
protectWorksheet(
wb,
sheet,
protect = TRUE,
password = NULL,
lockSelectingLockedCells = NULL,
lockSelectingUnlockedCells = NULL,
lockFormattingCells = NULL,
lockFormattingColumns = NULL,
lockFormattingRows = NULL,
lockInsertingColumns = NULL,
lockInsertingRows = NULL,
lockInsertingHyperlinks = NULL,
lockDeletingColumns = NULL,
lockDeletingRows = NULL,
lockSorting = NULL,
lockAutoFilter = NULL,
lockPivotTables = NULL,
lockObjects = NULL,
lockScenarios = NULL
)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{protect}{Whether to protect or unprotect the sheet (default=TRUE)}
\item{password}{(optional) password required to unprotect the worksheet}
\item{lockSelectingLockedCells}{Whether selecting locked cells is locked}
\item{lockSelectingUnlockedCells}{Whether selecting unlocked cells is locked}
\item{lockFormattingCells}{Whether formatting cells is locked}
\item{lockFormattingColumns}{Whether formatting columns is locked}
\item{lockFormattingRows}{Whether formatting rows is locked}
\item{lockInsertingColumns}{Whether inserting columns is locked}
\item{lockInsertingRows}{Whether inserting rows is locked}
\item{lockInsertingHyperlinks}{Whether inserting hyperlinks is locked}
\item{lockDeletingColumns}{Whether deleting columns is locked}
\item{lockDeletingRows}{Whether deleting rows is locked}
\item{lockSorting}{Whether sorting is locked}
\item{lockAutoFilter}{Whether auto-filter is locked}
\item{lockPivotTables}{Whether pivot tables are locked}
\item{lockObjects}{Whether objects are locked}
\item{lockScenarios}{Whether scenarios are locked}
}
\description{
Protect or unprotect a worksheet from modifications by the user in the graphical user interface. Replaces an existing protection.
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "S1")
writeDataTable(wb, 1, x = iris[1:30, ])
# Formatting cells / columns is allowed , but inserting / deleting columns is protected:
protectWorksheet(wb, "S1",
protect = TRUE,
lockFormattingCells = FALSE, lockFormattingColumns = FALSE,
lockInsertingColumns = TRUE, lockDeletingColumns = TRUE
)
# Remove the protection
protectWorksheet(wb, "S1", protect = FALSE)
\dontrun{
saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)
}
}
\author{
Reinhold Kainhofer
}
openxlsx/man/saveWorkbook.Rd 0000644 0001762 0000144 00000002305 14155600364 015654 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{saveWorkbook}
\alias{saveWorkbook}
\title{save Workbook to file}
\usage{
saveWorkbook(wb, file, overwrite = FALSE, returnValue = FALSE)
}
\arguments{
\item{wb}{A Workbook object to write to file}
\item{file}{A character string naming an xlsx file}
\item{overwrite}{If \code{TRUE}, overwrite any existing file.}
\item{returnValue}{If \code{TRUE}, returns \code{TRUE} in case of a success, else \code{FALSE}.
If flag is \code{FALSE}, then no return value is returned.}
}
\description{
save a Workbook object to file
}
\examples{
## Create a new workbook and add a worksheet
wb <- createWorkbook("Creator of workbook")
addWorksheet(wb, sheetName = "My first worksheet")
## Save workbook to working directory
\dontrun{
saveWorkbook(wb, file = "saveWorkbookExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=createWorkbook]{createWorkbook()}}
\code{\link[=addWorksheet]{addWorksheet()}}
\code{\link[=loadWorkbook]{loadWorkbook()}}
\code{\link[=writeData]{writeData()}}
\code{\link[=writeDataTable]{writeDataTable()}}
}
\author{
Alexander Walker, Philipp Schauberger
}
openxlsx/man/names.Rd 0000644 0001762 0000144 00000001177 14155600363 014310 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{names}
\alias{names}
\alias{names.Workbook}
\alias{names<-.Workbook}
\title{get or set worksheet names}
\usage{
\method{names}{Workbook}(x)
\method{names}{Workbook}(x) <- value
}
\arguments{
\item{x}{A \code{Workbook} object}
\item{value}{a character vector the same length as wb}
}
\description{
get or set worksheet names
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "S1")
addWorksheet(wb, "S2")
addWorksheet(wb, "S3")
names(wb)
names(wb)[[2]] <- "S2a"
names(wb)
names(wb) <- paste("Sheet", 1:3)
}
openxlsx/man/createWorkbook.Rd 0000644 0001762 0000144 00000002212 14155600363 016155 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{createWorkbook}
\alias{createWorkbook}
\title{Create a new Workbook object}
\usage{
createWorkbook(
creator = ifelse(.Platform$OS.type == "windows", Sys.getenv("USERNAME"),
Sys.getenv("USER")),
title = NULL,
subject = NULL,
category = NULL
)
}
\arguments{
\item{creator}{Creator of the workbook (your name). Defaults to login username}
\item{title}{Workbook properties title}
\item{subject}{Workbook properties subject}
\item{category}{Workbook properties category}
}
\value{
Workbook object
}
\description{
Create a new Workbook object
}
\examples{
## Create a new workbook
wb <- createWorkbook()
## Save workbook to working directory
\dontrun{
saveWorkbook(wb, file = "createWorkbookExample.xlsx", overwrite = TRUE)
}
## Set Workbook properties
wb <- createWorkbook(
creator = "Me",
title = "title here",
subject = "this & that",
category = "something"
)
}
\seealso{
\code{\link[=loadWorkbook]{loadWorkbook()}}
\code{\link[=saveWorkbook]{saveWorkbook()}}
}
\author{
Alexander Walker
}
openxlsx/man/worksheetOrder.Rd 0000644 0001762 0000144 00000002664 14155600364 016217 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{worksheetOrder}
\alias{worksheetOrder}
\alias{worksheetOrder<-}
\title{Order of worksheets in xlsx file}
\usage{
worksheetOrder(wb)
worksheetOrder(wb) <- value
}
\arguments{
\item{wb}{A workbook object}
\item{value}{Vector specifying order to write worksheets to file}
}
\description{
Get/set order of worksheets in a Workbook object
}
\details{
This function does not reorder the worksheets within the workbook object, it simply
shuffles the order when writing to file.
}
\examples{
## setup a workbook with 3 worksheets
wb <- createWorkbook()
addWorksheet(wb = wb, sheetName = "Sheet 1", gridLines = FALSE)
writeDataTable(wb = wb, sheet = 1, x = iris)
addWorksheet(wb = wb, sheetName = "mtcars (Sheet 2)", gridLines = FALSE)
writeData(wb = wb, sheet = 2, x = mtcars)
addWorksheet(wb = wb, sheetName = "Sheet 3", gridLines = FALSE)
writeData(wb = wb, sheet = 3, x = Formaldehyde)
worksheetOrder(wb)
names(wb)
worksheetOrder(wb) <- c(1, 3, 2) # switch position of sheets 2 & 3
writeData(wb, 2, 'This is still the "mtcars" worksheet', startCol = 15)
worksheetOrder(wb)
names(wb) ## ordering within workbook is not changed
\dontrun{
saveWorkbook(wb, "worksheetOrderExample.xlsx", overwrite = TRUE)
}
worksheetOrder(wb) <- c(3, 2, 1)
\dontrun{
saveWorkbook(wb, "worksheetOrderExample2.xlsx", overwrite = TRUE)
}
}
openxlsx/man/groupColumns.Rd 0000644 0001762 0000144 00000001537 14155600363 015702 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{groupColumns}
\alias{groupColumns}
\title{Group columns}
\usage{
groupColumns(wb, sheet, cols, hidden = FALSE)
}
\arguments{
\item{wb}{A workbook object.}
\item{sheet}{A name or index of a worksheet.}
\item{cols}{Indices of cols to group.}
\item{hidden}{Logical vector. If TRUE the grouped columns are hidden. Defaults to FALSE.}
}
\description{
Group a selection of columns
}
\details{
Group columns together, with the option to hide them.
NOTE: \code{\link[=setColWidths]{setColWidths()}} has a conflicting \code{hidden} parameter; changing one will update the other.
}
\seealso{
\code{\link[=ungroupColumns]{ungroupColumns()}} to ungroup columns. \code{\link[=groupRows]{groupRows()}} for grouping rows.
}
\author{
Joshua Sturm
}
openxlsx/man/cloneWorksheet.Rd 0000644 0001762 0000144 00000001467 14155600363 016203 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{cloneWorksheet}
\alias{cloneWorksheet}
\title{Clone a worksheet to a workbook}
\usage{
cloneWorksheet(wb, sheetName, clonedSheet)
}
\arguments{
\item{wb}{A Workbook object to attach the new worksheet}
\item{sheetName}{A name for the new worksheet}
\item{clonedSheet}{The name of the existing worksheet to be cloned.}
}
\value{
XML tree
}
\description{
Clone a worksheet to a Workbook object
}
\examples{
## Create a new workbook
wb <- createWorkbook("Fred")
## Add 3 worksheets
addWorksheet(wb, "Sheet 1")
cloneWorksheet(wb, "Sheet 2", clonedSheet = "Sheet 1")
## Save workbook
\dontrun{
saveWorkbook(wb, "cloneWorksheetExample.xlsx", overwrite = TRUE)
}
}
\author{
Reinhold Kainhofer
}
openxlsx/man/col2int.Rd 0000644 0001762 0000144 00000000515 14155600363 014552 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{col2int}
\alias{col2int}
\title{Convert Excel column to integer}
\usage{
col2int(x)
}
\arguments{
\item{x}{A character vector}
}
\description{
Converts an Excel column label to an integer.
}
\examples{
col2int(LETTERS)
}
openxlsx/man/conditionalFormatting.Rd 0000644 0001762 0000144 00000023506 14155600363 017543 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/conditional_formatting.R
\name{conditionalFormatting}
\alias{conditionalFormatting}
\alias{databar}
\title{Add conditional formatting to cells}
\usage{
conditionalFormatting(
wb,
sheet,
cols,
rows,
rule = NULL,
style = NULL,
type = "expression",
...
)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{Columns to apply conditional formatting to}
\item{rows}{Rows to apply conditional formatting to}
\item{rule}{The condition under which to apply the formatting. See examples.}
\item{style}{A style to apply to those cells that satisfy the rule. Default is createStyle(fontColour = "#9C0006", bgFill = "#FFC7CE")}
\item{type}{Either 'expression', 'colourScale', 'databar', 'duplicates', 'beginsWith',
'endsWith', 'topN', 'bottomN', 'contains' or 'notContains' (case insensitive).}
\item{...}{See below}
}
\description{
Add conditional formatting to cells
}
\details{
See Examples.
If type == "expression"
\itemize{
\item{style is a Style object. See \code{\link[=createStyle]{createStyle()}}}
\item{rule is an expression. Valid operators are "<", "<=", ">", ">=", "==", "!=".}
}
If type == "colourScale"
\itemize{
\item{style is a vector of colours with length 2 or 3}
\item{rule can be NULL or a vector of colours of equal length to styles}
}
If type == "databar"
\itemize{
\item{style is a vector of colours with length 2 or 3}
\item{rule is a numeric vector specifying the range of the databar colours. Must be equal length to style}
\item{...
\itemize{
\item{\strong{showvalue} If FALSE the cell value is hidden. Default TRUE.}
\item{\strong{gradient} If FALSE colour gradient is removed. Default TRUE.}
\item{\strong{border} If FALSE the border around the database is hidden. Default TRUE.}
}
}
}
If type == "duplicates"
\itemize{
\item{style is a Style object. See \code{\link[=createStyle]{createStyle()}}}
\item{rule is ignored.}
}
If type == "contains"
\itemize{
\item{style is a Style object. See \code{\link[=createStyle]{createStyle()}}}
\item{rule is the text to look for within cells}
}
If type == "between"
\itemize{
\item{style is a Style object. See \code{\link[=createStyle]{createStyle()}}}
\item{rule is a numeric vector of length 2 specifying lower and upper bound (Inclusive)}
}
If type == "topN"
\itemize{
\item{style is a Style object. See \code{\link[=createStyle]{createStyle()}}}
\item{rule is ignored}
\item{...
\itemize{
\item{\strong{rank} numeric vector of length 1 indicating number of highest values.}
\item{\strong{percent} TRUE if you want top N percentage.}
}
}
}
If type == "bottomN"
\itemize{
\item{style is a Style object. See \code{\link[=createStyle]{createStyle()}}}
\item{rule is ignored}
\item{...
\itemize{
\item{\strong{rank} numeric vector of length 1 indicating number of lowest values.}
\item{\strong{percent} TRUE if you want bottom N percentage.}
}
}
}
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "cellIs")
addWorksheet(wb, "Moving Row")
addWorksheet(wb, "Moving Col")
addWorksheet(wb, "Dependent on")
addWorksheet(wb, "Duplicates")
addWorksheet(wb, "containsText")
addWorksheet(wb, "notcontainsText")
addWorksheet(wb, "beginsWith")
addWorksheet(wb, "endsWith")
addWorksheet(wb, "colourScale", zoom = 30)
addWorksheet(wb, "databar")
addWorksheet(wb, "between")
addWorksheet(wb, "topN")
addWorksheet(wb, "bottomN")
addWorksheet(wb, "logical operators")
negStyle <- createStyle(fontColour = "#9C0006", bgFill = "#FFC7CE")
posStyle <- createStyle(fontColour = "#006100", bgFill = "#C6EFCE")
## rule applies to all each cell in range
writeData(wb, "cellIs", -5:5)
writeData(wb, "cellIs", LETTERS[1:11], startCol = 2)
conditionalFormatting(wb, "cellIs",
cols = 1,
rows = 1:11, rule = "!=0", style = negStyle
)
conditionalFormatting(wb, "cellIs",
cols = 1,
rows = 1:11, rule = "==0", style = posStyle
)
## highlight row dependent on first cell in row
writeData(wb, "Moving Row", -5:5)
writeData(wb, "Moving Row", LETTERS[1:11], startCol = 2)
conditionalFormatting(wb, "Moving Row",
cols = 1:2,
rows = 1:11, rule = "$A1<0", style = negStyle
)
conditionalFormatting(wb, "Moving Row",
cols = 1:2,
rows = 1:11, rule = "$A1>0", style = posStyle
)
## highlight column dependent on first cell in column
writeData(wb, "Moving Col", -5:5)
writeData(wb, "Moving Col", LETTERS[1:11], startCol = 2)
conditionalFormatting(wb, "Moving Col",
cols = 1:2,
rows = 1:11, rule = "A$1<0", style = negStyle
)
conditionalFormatting(wb, "Moving Col",
cols = 1:2,
rows = 1:11, rule = "A$1>0", style = posStyle
)
## highlight entire range cols X rows dependent only on cell A1
writeData(wb, "Dependent on", -5:5)
writeData(wb, "Dependent on", LETTERS[1:11], startCol = 2)
conditionalFormatting(wb, "Dependent on",
cols = 1:2,
rows = 1:11, rule = "$A$1<0", style = negStyle
)
conditionalFormatting(wb, "Dependent on",
cols = 1:2,
rows = 1:11, rule = "$A$1>0", style = posStyle
)
## highlight cells in column 1 based on value in column 2
writeData(wb, "Dependent on", data.frame(x = 1:10, y = runif(10)), startRow = 15)
conditionalFormatting(wb, "Dependent on",
cols = 1,
rows = 16:25, rule = "B16<0.5", style = negStyle
)
conditionalFormatting(wb, "Dependent on",
cols = 1,
rows = 16:25, rule = "B16>=0.5", style = posStyle
)
## highlight duplicates using default style
writeData(wb, "Duplicates", sample(LETTERS[1:15], size = 10, replace = TRUE))
conditionalFormatting(wb, "Duplicates", cols = 1, rows = 1:10, type = "duplicates")
## cells containing text
fn <- function(x) paste(sample(LETTERS, 10), collapse = "-")
writeData(wb, "containsText", sapply(1:10, fn))
conditionalFormatting(wb, "containsText", cols = 1, rows = 1:10, type = "contains", rule = "A")
## cells not containing text
fn <- function(x) paste(sample(LETTERS, 10), collapse = "-")
writeData(wb, "containsText", sapply(1:10, fn))
conditionalFormatting(wb, "notcontainsText", cols = 1,
rows = 1:10, type = "notcontains", rule = "A")
## cells begins with text
fn <- function(x) paste(sample(LETTERS, 10), collapse = "-")
writeData(wb, "beginsWith", sapply(1:100, fn))
conditionalFormatting(wb, "beginsWith", cols = 1, rows = 1:100, type = "beginsWith", rule = "A")
## cells ends with text
fn <- function(x) paste(sample(LETTERS, 10), collapse = "-")
writeData(wb, "endsWith", sapply(1:100, fn))
conditionalFormatting(wb, "endsWith", cols = 1, rows = 1:100, type = "endsWith", rule = "A")
## colourscale colours cells based on cell value
df <- read.xlsx(system.file("extdata", "readTest.xlsx", package = "openxlsx"), sheet = 4)
writeData(wb, "colourScale", df, colNames = FALSE) ## write data.frame
## rule is a vector or colours of length 2 or 3 (any hex colour or any of colours())
## If rule is NULL, min and max of cells is used. Rule must be the same length as style or NULL.
conditionalFormatting(wb, "colourScale",
cols = 1:ncol(df), rows = 1:nrow(df),
style = c("black", "white"),
rule = c(0, 255),
type = "colourScale"
)
setColWidths(wb, "colourScale", cols = 1:ncol(df), widths = 1.07)
setRowHeights(wb, "colourScale", rows = 1:nrow(df), heights = 7.5)
## Databars
writeData(wb, "databar", -5:5)
conditionalFormatting(wb, "databar", cols = 1, rows = 1:11, type = "databar") ## Default colours
## Between
# Highlight cells in interval [-2, 2]
writeData(wb, "between", -5:5)
conditionalFormatting(wb, "between", cols = 1, rows = 1:11, type = "between", rule = c(-2, 2))
## Top N
writeData(wb, "topN", data.frame(x = 1:10, y = rnorm(10)))
# Highlight top 5 values in column x
conditionalFormatting(wb, "topN", cols = 1, rows = 2:11,
style = posStyle, type = "topN", rank = 5)#'
# Highlight top 20 percentage in column y
conditionalFormatting(wb, "topN", cols = 2, rows = 2:11,
style = posStyle, type = "topN", rank = 20, percent = TRUE)
## Bottom N
writeData(wb, "bottomN", data.frame(x = 1:10, y = rnorm(10)))
# Highlight bottom 5 values in column x
conditionalFormatting(wb, "bottomN", cols = 1, rows = 2:11,
style = negStyle, type = "topN", rank = 5)
# Highlight bottom 20 percentage in column y
conditionalFormatting(wb, "bottomN", cols = 2, rows = 2:11,
style = negStyle, type = "topN", rank = 20, percent = TRUE)
## Logical Operators
# You can use Excels logical Operators
writeData(wb, "logical operators", 1:10)
conditionalFormatting(wb, "logical operators",
cols = 1, rows = 1:10,
rule = "OR($A1=1,$A1=3,$A1=5,$A1=7)"
)
\dontrun{
saveWorkbook(wb, "conditionalFormattingExample.xlsx", TRUE)
}
#########################################################################
## Databar Example
wb <- createWorkbook()
addWorksheet(wb, "databar")
## Databars
writeData(wb, "databar", -5:5, startCol = 1)
conditionalFormatting(wb, "databar", cols = 1, rows = 1:11, type = "databar") ## Defaults
writeData(wb, "databar", -5:5, startCol = 3)
conditionalFormatting(wb, "databar", cols = 3, rows = 1:11, type = "databar", border = FALSE)
writeData(wb, "databar", -5:5, startCol = 5)
conditionalFormatting(wb, "databar",
cols = 5, rows = 1:11,
type = "databar", style = c("#a6a6a6"), showValue = FALSE
)
writeData(wb, "databar", -5:5, startCol = 7)
conditionalFormatting(wb, "databar",
cols = 7, rows = 1:11,
type = "databar", style = c("#a6a6a6"), showValue = FALSE, gradient = FALSE
)
writeData(wb, "databar", -5:5, startCol = 9)
conditionalFormatting(wb, "databar",
cols = 9, rows = 1:11,
type = "databar", style = c("#a6a6a6", "#a6a6a6"), showValue = FALSE, gradient = FALSE
)
\dontrun{
saveWorkbook(wb, file = "databarExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=createStyle]{createStyle()}}
}
\author{
Alexander Walker, Philipp Schauberger
}
openxlsx/man/removeTable.Rd 0000644 0001762 0000144 00000002661 14155600363 015451 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{removeTable}
\alias{removeTable}
\title{Remove an Excel table in a workbook}
\usage{
removeTable(wb, sheet, table)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{table}{Name of table to remove. See \code{\link[=getTables]{getTables()}}}
}
\value{
character vector of table names on the specified sheet
}
\description{
List Excel tables in a workbook
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, sheetName = "Sheet 1")
addWorksheet(wb, sheetName = "Sheet 2")
writeDataTable(wb, sheet = "Sheet 1", x = iris, tableName = "iris")
writeDataTable(wb, sheet = 1, x = mtcars, tableName = "mtcars", startCol = 10)
removeWorksheet(wb, sheet = 1) ## delete worksheet removes table objects
writeDataTable(wb, sheet = 1, x = iris, tableName = "iris")
writeDataTable(wb, sheet = 1, x = mtcars, tableName = "mtcars", startCol = 10)
## removeTable() deletes table object and all data
getTables(wb, sheet = 1)
removeTable(wb = wb, sheet = 1, table = "iris")
writeDataTable(wb, sheet = 1, x = iris, tableName = "iris", startCol = 1)
getTables(wb, sheet = 1)
removeTable(wb = wb, sheet = 1, table = "iris")
writeDataTable(wb, sheet = 1, x = iris, tableName = "iris", startCol = 1)
\dontrun{
saveWorkbook(wb = wb, file = "removeTableExample.xlsx", overwrite = TRUE)
}
}
openxlsx/man/sheetVisible.Rd 0000644 0001762 0000144 00000001560 14155600364 015630 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{sheetVisible}
\alias{sheetVisible}
\alias{sheetVisible<-}
\title{Get worksheet visible state.}
\usage{
sheetVisible(wb)
sheetVisible(wb) <- value
}
\arguments{
\item{wb}{A workbook object}
\item{value}{a logical vector the same length as sheetVisible(wb)}
}
\value{
Character vector of worksheet names.
TRUE if sheet is visible, FALSE if sheet is hidden
}
\description{
DEPRECATED - Use function 'sheetVisibility()
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, sheetName = "S1", visible = FALSE)
addWorksheet(wb, sheetName = "S2", visible = TRUE)
addWorksheet(wb, sheetName = "S3", visible = FALSE)
sheetVisible(wb)
sheetVisible(wb)[1] <- TRUE ## show sheet 1
sheetVisible(wb)[2] <- FALSE ## hide sheet 2
}
\author{
Alexander Walker
}
openxlsx/man/addWorksheet.Rd 0000644 0001762 0000144 00000010167 14155600363 015630 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{addWorksheet}
\alias{addWorksheet}
\title{Add a worksheet to a workbook}
\usage{
addWorksheet(
wb,
sheetName,
gridLines = openxlsx_getOp("gridLines", TRUE),
tabColour = NULL,
zoom = 100,
header = openxlsx_getOp("header"),
footer = openxlsx_getOp("footer"),
evenHeader = openxlsx_getOp("evenHeader"),
evenFooter = openxlsx_getOp("evenFooter"),
firstHeader = openxlsx_getOp("firstHeader"),
firstFooter = openxlsx_getOp("firstFooter"),
visible = TRUE,
paperSize = openxlsx_getOp("paperSize", 9),
orientation = openxlsx_getOp("orientation", "portrait"),
vdpi = openxlsx_getOp("vdpi", 300),
hdpi = openxlsx_getOp("hdpi", 300)
)
}
\arguments{
\item{wb}{A Workbook object to attach the new worksheet}
\item{sheetName}{A name for the new worksheet}
\item{gridLines}{A logical. If \code{FALSE}, the worksheet grid lines will be hidden.}
\item{tabColour}{Colour of the worksheet tab. A valid colour (belonging to colours()) or a valid hex colour beginning with "#"}
\item{zoom}{A numeric between 10 and 400. Worksheet zoom level as a percentage.}
\item{header}{document header. Character vector of length 3 corresponding to positions left, center, right. Use NA to skip a position.}
\item{footer}{document footer. Character vector of length 3 corresponding to positions left, center, right. Use NA to skip a position.}
\item{evenHeader}{document header for even pages.}
\item{evenFooter}{document footer for even pages.}
\item{firstHeader}{document header for first page only.}
\item{firstFooter}{document footer for first page only.}
\item{visible}{If FALSE, sheet is hidden else visible.}
\item{paperSize}{An integer corresponding to a paper size. See ?pageSetup for details.}
\item{orientation}{One of "portrait" or "landscape"}
\item{vdpi}{Vertical DPI. Can be set with options("openxlsx.dpi" = X) or options("openxlsx.vdpi" = X)}
\item{hdpi}{Horizontal DPI. Can be set with options("openxlsx.dpi" = X) or options("openxlsx.hdpi" = X)}
}
\value{
XML tree
}
\description{
Add a worksheet to a Workbook object
}
\details{
Headers and footers can contain special tags
\itemize{
\item{\strong{&[Page]}}{ Page number}
\item{\strong{&[Pages]}}{ Number of pages}
\item{\strong{&[Date]}}{ Current date}
\item{\strong{&[Time]}}{ Current time}
\item{\strong{&[Path]}}{ File path}
\item{\strong{&[File]}}{ File name}
\item{\strong{&[Tab]}}{ Worksheet name}
}
}
\examples{
## Create a new workbook
wb <- createWorkbook("Fred")
## Add 3 worksheets
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2", gridLines = FALSE)
addWorksheet(wb, "Sheet 3", tabColour = "red")
addWorksheet(wb, "Sheet 4", gridLines = FALSE, tabColour = "#4F81BD")
## Headers and Footers
addWorksheet(wb, "Sheet 5",
header = c("ODD HEAD LEFT", "ODD HEAD CENTER", "ODD HEAD RIGHT"),
footer = c("ODD FOOT RIGHT", "ODD FOOT CENTER", "ODD FOOT RIGHT"),
evenHeader = c("EVEN HEAD LEFT", "EVEN HEAD CENTER", "EVEN HEAD RIGHT"),
evenFooter = c("EVEN FOOT RIGHT", "EVEN FOOT CENTER", "EVEN FOOT RIGHT"),
firstHeader = c("TOP", "OF FIRST", "PAGE"),
firstFooter = c("BOTTOM", "OF FIRST", "PAGE")
)
addWorksheet(wb, "Sheet 6",
header = c("&[Date]", "ALL HEAD CENTER 2", "&[Page] / &[Pages]"),
footer = c("&[Path]&[File]", NA, "&[Tab]"),
firstHeader = c(NA, "Center Header of First Page", NA),
firstFooter = c(NA, "Center Footer of First Page", NA)
)
addWorksheet(wb, "Sheet 7",
header = c("ALL HEAD LEFT 2", "ALL HEAD CENTER 2", "ALL HEAD RIGHT 2"),
footer = c("ALL FOOT RIGHT 2", "ALL FOOT CENTER 2", "ALL FOOT RIGHT 2")
)
addWorksheet(wb, "Sheet 8",
firstHeader = c("FIRST ONLY L", NA, "FIRST ONLY R"),
firstFooter = c("FIRST ONLY L", NA, "FIRST ONLY R")
)
## Need data on worksheet to see all headers and footers
writeData(wb, sheet = 5, 1:400)
writeData(wb, sheet = 6, 1:400)
writeData(wb, sheet = 7, 1:400)
writeData(wb, sheet = 8, 1:400)
## Save workbook
\dontrun{
saveWorkbook(wb, "addWorksheetExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker
}
openxlsx/man/buildWorkbook.Rd 0000644 0001762 0000144 00000010364 14155600363 016020 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build_workbook.R
\name{buildWorkbook}
\alias{buildWorkbook}
\title{Build Workbook}
\usage{
buildWorkbook(x, asTable = FALSE, ...)
}
\arguments{
\item{x}{A data.frame or a (named) list of objects that can be handled by
\code{\link[=writeData]{writeData()}} or \code{\link[=writeDataTable]{writeDataTable()}} to write to file}
\item{asTable}{If \code{TRUE} will use \code{\link[=writeDataTable]{writeDataTable()}} rather
than \code{\link[=writeData]{writeData()}} to write \code{x} to the file (default:
\code{FALSE})}
\item{...}{Additional arguments passed to \code{\link[=writeData]{writeData()}},
\code{\link[=writeDataTable]{writeDataTable()}}, \code{\link[=setColWidths]{setColWidths()}} (see Optional
Parameters)}
}
\value{
A Workbook object
}
\description{
Build a workbook from a data.frame or named list
}
\details{
This function can be used as shortcut to create a workbook object from a
data.frame or named list. If names are available in the list they will be
used as the worksheet names. The parameters in \code{...} are collected
and passed to \code{\link[=writeData]{writeData()}} or \code{\link[=writeDataTable]{writeDataTable()}} to
initially create the Workbook objects then appropriate parameters are
passed to \code{\link[=setColWidths]{setColWidths()}}.
columns of x with class Date or POSIXt are automatically
styled as dates and datetimes respectively.
}
\section{Optional Parameters}{
\strong{createWorkbook Parameters}
\itemize{
\item{\strong{creator}}{ A string specifying the workbook author}
}
\strong{addWorksheet Parameters}
\itemize{
\item{\strong{sheetName}}{ Name of the worksheet}
\item{\strong{gridLines}}{ A logical. If \code{FALSE}, the worksheet grid lines will be hidden.}
\item{\strong{tabColour}}{ Colour of the worksheet tab. A valid colour (belonging to colours())
or a valid hex colour beginning with "#".}
\item{\strong{zoom}}{ A numeric between 10 and 400. Worksheet zoom level as a percentage.}
}
\strong{writeData/writeDataTable Parameters}
\itemize{
\item{\strong{startCol}}{ A vector specifying the starting column(s) to write df}
\item{\strong{startRow}}{ A vector specifying the starting row(s) to write df}
\item{\strong{xy}}{ An alternative to specifying startCol and startRow individually.
A vector of the form c(startCol, startRow)}
\item{\strong{colNames or col.names}}{ If \code{TRUE}, column names of x are written.}
\item{\strong{rowNames or row.names}}{ If \code{TRUE}, row names of x are written.}
\item{\strong{headerStyle}}{ Custom style to apply to column names.}
\item{\strong{borders}}{ Either "surrounding", "columns" or "rows" or NULL. If "surrounding", a border is drawn around the
data. If "rows", a surrounding border is drawn a border around each row. If "columns", a surrounding border is drawn with a border
between each column. If "\code{all}" all cell borders are drawn.}
\item{\strong{borderColour}}{ Colour of cell border}
\item{\strong{borderStyle}}{ Border line style.}
\item{\strong{keepNA}} {If \code{TRUE}, NA values are converted to #N/A (or \code{na.string}, if not NULL) in Excel, else NA cells will be empty. Defaults to FALSE.}
\item{\strong{na.string}} {If not NULL, and if \code{keepNA} is \code{TRUE}, NA values are converted to this string in Excel. Defaults to NULL.}
}
\strong{freezePane Parameters}
\itemize{
\item{\strong{firstActiveRow}} {Top row of active region to freeze pane.}
\item{\strong{firstActiveCol}} {Furthest left column of active region to freeze pane.}
\item{\strong{firstRow}} {If \code{TRUE}, freezes the first row (equivalent to firstActiveRow = 2)}
\item{\strong{firstCol}} {If \code{TRUE}, freezes the first column (equivalent to firstActiveCol = 2)}
}
\strong{colWidths Parameters}
\itemize{
\item{\strong{colWidths}} {May be a single value for all columns (or "auto"), or a list of vectors that will be recycled for each sheet (see examples)}
}
}
\examples{
x <- data.frame(a = 1, b = 2)
wb <- buildWorkbook(x)
y <- list(a = x, b = x, c = x)
buildWorkbook(y, asTable = TRUE)
buildWorkbook(y, asTable = TRUE, tableStyle = "TableStyleLight8")
}
\seealso{
\code{\link[=write.xlsx]{write.xlsx()}}
}
\author{
Jordan Mark Barbone
}
openxlsx/man/int2col.Rd 0000644 0001762 0000144 00000000510 14155600363 014545 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{int2col}
\alias{int2col}
\title{Convert integer to Excel column}
\usage{
int2col(x)
}
\arguments{
\item{x}{A numeric vector}
}
\description{
Converts an integer to an Excel column label.
}
\examples{
int2col(1:10)
}
openxlsx/man/read.xlsx.Rd 0000644 0001762 0000144 00000007072 14155600363 015115 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/readWorkbook.R
\name{read.xlsx}
\alias{read.xlsx}
\title{Read from an Excel file or Workbook object}
\usage{
read.xlsx(
xlsxFile,
sheet,
startRow = 1,
colNames = TRUE,
rowNames = FALSE,
detectDates = FALSE,
skipEmptyRows = TRUE,
skipEmptyCols = TRUE,
rows = NULL,
cols = NULL,
check.names = FALSE,
sep.names = ".",
namedRegion = NULL,
na.strings = "NA",
fillMergedCells = FALSE
)
}
\arguments{
\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.}
\item{sheet}{The name or index of the sheet to read data from.}
\item{startRow}{first row to begin looking for data. Empty rows at the top of a file are always skipped,
regardless of the value of startRow.}
\item{colNames}{If \code{TRUE}, the first row of data will be used as column names.}
\item{rowNames}{If \code{TRUE}, first column of data will be used as row names.}
\item{detectDates}{If \code{TRUE}, attempt to recognise dates and perform conversion.}
\item{skipEmptyRows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data
will return a row of NAs.}
\item{skipEmptyCols}{If \code{TRUE}, empty columns are skipped.}
\item{rows}{A numeric vector specifying which rows in the Excel file to read.
If NULL, all rows are read.}
\item{cols}{A numeric vector specifying which columns in the Excel file to read.
If NULL, all columns are read.}
\item{check.names}{logical. If TRUE then the names of the variables in the data frame
are checked to ensure that they are syntactically valid variable names}
\item{sep.names}{One character which substitutes blanks in column names. By default, "."}
\item{namedRegion}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.}
\item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.}
\item{fillMergedCells}{If TRUE, the value in a merged cell is given to all cells within the merge.}
}
\value{
data.frame
}
\description{
Read data from an Excel file or Workbook object into a data.frame
}
\details{
Formulae written using writeFormula to a Workbook object will not get picked up by read.xlsx().
This is because only the formula is written and left to be evaluated when the file is opened in Excel.
Opening, saving and closing the file with Excel will resolve this.
}
\examples{
xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx")
df1 <- read.xlsx(xlsxFile = xlsxFile, sheet = 1, skipEmptyRows = FALSE)
sapply(df1, class)
df2 <- read.xlsx(xlsxFile = xlsxFile, sheet = 3, skipEmptyRows = TRUE)
df2$Date <- convertToDate(df2$Date)
sapply(df2, class)
head(df2)
df2 <- read.xlsx(
xlsxFile = xlsxFile, sheet = 3, skipEmptyRows = TRUE,
detectDates = TRUE
)
sapply(df2, class)
head(df2)
wb <- loadWorkbook(system.file("extdata", "readTest.xlsx", package = "openxlsx"))
df3 <- read.xlsx(wb, sheet = 2, skipEmptyRows = FALSE, colNames = TRUE)
df4 <- read.xlsx(xlsxFile, sheet = 2, skipEmptyRows = FALSE, colNames = TRUE)
all.equal(df3, df4)
wb <- loadWorkbook(system.file("extdata", "readTest.xlsx", package = "openxlsx"))
df3 <- read.xlsx(wb,
sheet = 2, skipEmptyRows = FALSE,
cols = c(1, 4), rows = c(1, 3, 4)
)
## URL
##
\dontrun{
xlsxFile <- "https://github.com/awalker89/openxlsx/raw/master/inst/readTest.xlsx"
head(read.xlsx(xlsxFile))
}
}
\seealso{
\code{\link[=getNamedRegions]{getNamedRegions()}}
}
\author{
Alexander Walker
}
openxlsx/man/openXL.Rd 0000644 0001762 0000144 00000002506 14155600363 014407 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/openXL.R
\name{openXL}
\alias{openXL}
\title{Open a Microsoft Excel file (xls/xlsx) or an openxlsx Workbook}
\usage{
openXL(file=NULL)
}
\arguments{
\item{file}{path to the Excel (xls/xlsx) file or Workbook object.}
}
\description{
This function tries to open a Microsoft Excel
(xls/xlsx) file or an openxlsx Workbook with the proper
application, in a portable manner.
In Windows (c) and Mac (c), it uses system default handlers,
given the file type.
In Linux it searches (via \code{which}) for available xls/xlsx
reader applications (unless \code{options('openxlsx.excelApp')}
is set to the app bin path), and if it finds anything, sets
\code{options('openxlsx.excelApp')} to the program choosen by
the user via a menu (if many are present, otherwise it will
set the only available). Currently searched for apps are
Libreoffice/Openoffice (\code{soffice} bin), Gnumeric
(\code{gnumeric}) and Calligra Sheets (\code{calligrasheets}).
}
\examples{
# file example
example(writeData)
# openXL("writeDataExample.xlsx")
# (not yet saved) Workbook example
wb <- createWorkbook()
x <- mtcars[1:6, ]
addWorksheet(wb, "Cars")
writeData(wb, "Cars", x, startCol = 2, startRow = 3, rowNames = TRUE)
# openXL(wb)
}
\author{
Luca Braglia
}
openxlsx/man/openxlsx.Rd 0000644 0001762 0000144 00000003346 14155600363 015065 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/openxlsx.R
\docType{package}
\name{openxlsx}
\alias{openxlsx}
\title{xlsx reading, writing and editing.}
\description{
openxlsx simplifies the the process of writing and styling Excel xlsx files from R
and removes the dependency on Java.
}
\details{
The openxlsx package uses global options, most to simplify formatting. These
are stored in the \code{op.openxlsx} object.
\describe{
\item{openxlsx.bandedCols}{FALSE}
\item{openxlsx.bandedRows}{TRUE}
\item{openxlsx.borderColour}{"black"}
\item{openxlsx.borders}{"none"}
\item{openxlsx.borderStyle}{"thin"}
\item{openxlsx.compressionLevel}{"9"}
\item{openxlsx.creator}{""}
\item{openxlsx.dateFormat}{"mm/dd/yyyy"}
\item{openxlsx.datetimeFormat}{"yyyy-mm-dd hh:mm:ss"}
\item{openxlsx.headerStyle}{NULL}
\item{openxlsx.keepNA}{FALSE}
\item{openxlsx.na.string}{NULL}
\item{openxlsx.numFmt}{NULL}
\item{openxlsx.orientation}{"portrait"}
\item{openxlsx.paperSize}{9}
\item{openxlsx.tabColour}{"TableStyleLight9"}
\item{openxlsx.tableStyle}{"TableStyleLight9"}
\item{openxlsx.withFilter}{NA Whether to write data with or without a
filter. If NA will make filters with \code{writeDataTable} and will not for
\code{writeData}}
}
See the Formatting vignette for examples.
Additional options
}
\seealso{
\itemize{
\item{\code{vignette("Introduction", package = "openxlsx")}}
\item{\code{vignette("formatting", package = "openxlsx")}}
\item{\code{\link[=writeData]{writeData()}}}
\item{\code{\link[=writeDataTable]{writeDataTable()}}}
\item{\code{\link[=write.xlsx]{write.xlsx()}}}
\item{\code{\link[=read.xlsx]{read.xlsx()}}}
\item{\code{\link[=op.openxlsx]{op.openxlsx()}}}
}
for examples
}
openxlsx/man/getCreators.Rd 0000644 0001762 0000144 00000000721 14155600363 015461 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{getCreators}
\alias{getCreators}
\title{Add another author to the meta data of the file.}
\usage{
getCreators(wb)
}
\arguments{
\item{wb}{A workbook object}
}
\value{
vector of creators
}
\description{
Just a wrapper of wb$getCreators()
Get the names of the
}
\examples{
wb <- createWorkbook()
getCreators(wb)
}
\author{
Philipp Schauberger
}
openxlsx/man/removeWorksheet.Rd 0000644 0001762 0000144 00000001337 14155600364 016375 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{removeWorksheet}
\alias{removeWorksheet}
\title{Remove a worksheet from a workbook}
\usage{
removeWorksheet(wb, sheet)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
}
\description{
Remove a worksheet from a Workbook object
Remove a worksheet from a workbook
}
\examples{
## load a workbook
wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx"))
## Remove sheet 2
removeWorksheet(wb, 2)
## save the modified workbook
\dontrun{
saveWorkbook(wb, "removeWorksheetExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker
}
openxlsx/man/sheetVisibility.Rd 0000644 0001762 0000144 00000001735 14155600364 016366 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{sheetVisibility}
\alias{sheetVisibility}
\alias{sheetVisibility<-}
\title{Get/set worksheet visible state}
\usage{
sheetVisibility(wb)
sheetVisibility(wb) <- value
}
\arguments{
\item{wb}{A workbook object}
\item{value}{a logical/character vector the same length as sheetVisibility(wb)}
}
\value{
Character vector of worksheet names.
Vector of "hidden", "visible", "veryHidden"
}
\description{
Get and set worksheet visible state
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, sheetName = "S1", visible = FALSE)
addWorksheet(wb, sheetName = "S2", visible = TRUE)
addWorksheet(wb, sheetName = "S3", visible = FALSE)
sheetVisibility(wb)
sheetVisibility(wb)[1] <- TRUE ## show sheet 1
sheetVisibility(wb)[2] <- FALSE ## hide sheet 2
sheetVisibility(wb)[3] <- "hidden" ## hide sheet 3
sheetVisibility(wb)[3] <- "veryHidden" ## hide sheet 3 from UI
}
openxlsx/man/showGridLines.Rd 0000644 0001762 0000144 00000001503 14155600364 015760 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{showGridLines}
\alias{showGridLines}
\title{Set worksheet gridlines to show or hide.}
\usage{
showGridLines(wb, sheet, showGridLines = FALSE)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{showGridLines}{A logical. If \code{FALSE}, grid lines are hidden.}
}
\description{
Set worksheet gridlines to show or hide.
}
\examples{
wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx"))
names(wb) ## list worksheets in workbook
showGridLines(wb, 1, showGridLines = FALSE)
showGridLines(wb, "testing", showGridLines = FALSE)
\dontrun{
saveWorkbook(wb, "showGridLinesExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker
}
openxlsx/man/writeDataTable.Rd 0000644 0001762 0000144 00000014076 14155600364 016104 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/writeDataTable.R
\name{writeDataTable}
\alias{writeDataTable}
\title{Write to a worksheet as an Excel table}
\usage{
writeDataTable(
wb,
sheet,
x,
startCol = 1,
startRow = 1,
xy = NULL,
colNames = TRUE,
rowNames = FALSE,
tableStyle = openxlsx_getOp("tableStyle", "TableStyleLight9"),
tableName = NULL,
headerStyle = openxlsx_getOp("headerStyle"),
withFilter = openxlsx_getOp("withFilter", TRUE),
keepNA = openxlsx_getOp("keepNA", FALSE),
na.string = openxlsx_getOp("na.string"),
sep = ", ",
stack = FALSE,
firstColumn = openxlsx_getOp("firstColumn", FALSE),
lastColumn = openxlsx_getOp("lastColumn", FALSE),
bandedRows = openxlsx_getOp("bandedRows", TRUE),
bandedCols = openxlsx_getOp("bandedCols", FALSE),
col.names,
row.names
)
}
\arguments{
\item{wb}{A Workbook object containing a
worksheet.}
\item{sheet}{The worksheet to write to. Can be the worksheet index or name.}
\item{x}{A dataframe.}
\item{startCol}{A vector specifying the starting column to write df}
\item{startRow}{A vector specifying the starting row to write df}
\item{xy}{An alternative to specifying startCol and startRow individually.
A vector of the form c(startCol, startRow)}
\item{colNames}{If \code{TRUE}, column names of x are written.}
\item{rowNames}{If \code{TRUE}, row names of x are written.}
\item{tableStyle}{Any excel table style name or "none" (see "formatting" vignette).}
\item{tableName}{name of table in workbook. The table name must be unique.}
\item{headerStyle}{Custom style to apply to column names.}
\item{withFilter}{If \code{TRUE} or \code{NA}, columns with have filters in the first row.}
\item{keepNA}{If \code{TRUE}, NA values are converted to #N/A (or \code{na.string}, if not NULL) in Excel, else NA cells will be empty.}
\item{na.string}{If not NULL, and if \code{keepNA} is \code{TRUE}, NA values are converted to this string in Excel.}
\item{sep}{Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = sep).}
\item{stack}{If \code{TRUE} the new style is merged with any existing cell styles. If FALSE, any
existing style is replaced by the new style.
\cr\cr
\cr\strong{The below options correspond to Excel table options:}
\cr
\if{html}{\figure{tableoptions.png}{options: width="40\%" alt="Figure: table_options.png"}}
\if{latex}{\figure{tableoptions.pdf}{options: width=7cm}}}
\item{firstColumn}{logical. If TRUE, the first column is bold}
\item{lastColumn}{logical. If TRUE, the last column is bold}
\item{bandedRows}{logical. If TRUE, rows are colour banded}
\item{bandedCols}{logical. If TRUE, the columns are colour banded}
\item{row.names, col.names}{Deprecated, please use \code{rowNames}, \code{colNames} instead}
}
\description{
Write to a worksheet and format as an Excel table
}
\details{
columns of x with class Date/POSIXt, currency, accounting,
hyperlink, percentage are automatically styled as dates, currency, accounting,
hyperlinks, percentages respectively.
}
\examples{
## see package vignettes for further examples.
#####################################################################################
## Create Workbook object and add worksheets
wb <- createWorkbook()
addWorksheet(wb, "S1")
addWorksheet(wb, "S2")
addWorksheet(wb, "S3")
#####################################################################################
## -- write data.frame as an Excel table with column filters
## -- default table style is "TableStyleMedium2"
writeDataTable(wb, "S1", x = iris)
writeDataTable(wb, "S2",
x = mtcars, xy = c("B", 3), rowNames = TRUE,
tableStyle = "TableStyleLight9"
)
df <- data.frame(
"Date" = Sys.Date() - 0:19,
"T" = TRUE, "F" = FALSE,
"Time" = Sys.time() - 0:19 * 60 * 60,
"Cash" = paste("$", 1:20), "Cash2" = 31:50,
"hLink" = "https://CRAN.R-project.org/",
"Percentage" = seq(0, 1, length.out = 20),
"TinyNumbers" = runif(20) / 1E9, stringsAsFactors = FALSE
)
## openxlsx will apply default Excel styling for these classes
class(df$Cash) <- c(class(df$Cash), "currency")
class(df$Cash2) <- c(class(df$Cash2), "accounting")
class(df$hLink) <- "hyperlink"
class(df$Percentage) <- c(class(df$Percentage), "percentage")
class(df$TinyNumbers) <- c(class(df$TinyNumbers), "scientific")
writeDataTable(wb, "S3", x = df, startRow = 4, rowNames = TRUE, tableStyle = "TableStyleMedium9")
#####################################################################################
## Additional Header Styling and remove column filters
writeDataTable(wb,
sheet = 1, x = iris, startCol = 7, headerStyle = createStyle(textRotation = 45),
withFilter = FALSE
)
#####################################################################################
## Save workbook
## Open in excel without saving file: openXL(wb)
\dontrun{
saveWorkbook(wb, "writeDataTableExample.xlsx", overwrite = TRUE)
}
#####################################################################################
## Pre-defined table styles gallery
wb <- createWorkbook(paste0("tableStylesGallery.xlsx"))
addWorksheet(wb, "Style Samples")
for (i in 1:21) {
style <- paste0("TableStyleLight", i)
writeDataTable(wb,
x = data.frame(style), sheet = 1,
tableStyle = style, startRow = 1, startCol = i * 3 - 2
)
}
for (i in 1:28) {
style <- paste0("TableStyleMedium", i)
writeDataTable(wb,
x = data.frame(style), sheet = 1,
tableStyle = style, startRow = 4, startCol = i * 3 - 2
)
}
for (i in 1:11) {
style <- paste0("TableStyleDark", i)
writeDataTable(wb,
x = data.frame(style), sheet = 1,
tableStyle = style, startRow = 7, startCol = i * 3 - 2
)
}
## openXL(wb)
\dontrun{
saveWorkbook(wb, file = "tableStylesGallery.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=addWorksheet]{addWorksheet()}}
\code{\link[=writeData]{writeData()}}
\code{\link[=removeTable]{removeTable()}}
\code{\link[=getTables]{getTables()}}
}
openxlsx/man/writeComment.Rd 0000644 0001762 0000144 00000002436 14155600364 015662 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CommentClass.R
\name{writeComment}
\alias{writeComment}
\title{write a cell comment}
\usage{
writeComment(wb, sheet, col, row, comment, xy = NULL)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A vector of names or indices of worksheets}
\item{col}{Column a column number of letter}
\item{row}{A row number.}
\item{comment}{A Comment object. See \code{\link[=createComment]{createComment()}}.}
\item{xy}{An alternative to specifying \code{col} and
\code{row} individually. A vector of the form
\code{c(col, row)}.}
}
\description{
Write a Comment object to a worksheet
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
c1 <- createComment(comment = "this is comment")
writeComment(wb, 1, col = "B", row = 10, comment = c1)
s1 <- createStyle(fontSize = 12, fontColour = "red", textDecoration = c("BOLD"))
s2 <- createStyle(fontSize = 9, fontColour = "black")
c2 <- createComment(comment = c("This Part Bold red\n\n", "This part black"), style = c(s1, s2))
c2
writeComment(wb, 1, col = 6, row = 3, comment = c2)
\dontrun{
saveWorkbook(wb, file = "writeCommentExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=createComment]{createComment()}}
}
openxlsx/man/freezePane.Rd 0000644 0001762 0000144 00000002544 14155600363 015270 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{freezePane}
\alias{freezePane}
\title{Freeze a worksheet pane}
\usage{
freezePane(
wb,
sheet,
firstActiveRow = NULL,
firstActiveCol = NULL,
firstRow = FALSE,
firstCol = FALSE
)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{firstActiveRow}{Top row of active region}
\item{firstActiveCol}{Furthest left column of active region}
\item{firstRow}{If \code{TRUE}, freezes the first row (equivalent to firstActiveRow = 2)}
\item{firstCol}{If \code{TRUE}, freezes the first column (equivalent to firstActiveCol = 2)}
}
\description{
Freeze a worksheet pane
}
\examples{
## Create a new workbook
wb <- createWorkbook("Kenshin")
## Add some worksheets
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2")
addWorksheet(wb, "Sheet 3")
addWorksheet(wb, "Sheet 4")
## Freeze Panes
freezePane(wb, "Sheet 1", firstActiveRow = 5, firstActiveCol = 3)
freezePane(wb, "Sheet 2", firstCol = TRUE) ## shortcut to firstActiveCol = 2
freezePane(wb, 3, firstRow = TRUE) ## shortcut to firstActiveRow = 2
freezePane(wb, 4, firstActiveRow = 1, firstActiveCol = "D")
## Save workbook
\dontrun{
saveWorkbook(wb, "freezePaneExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker
}
openxlsx/man/convertToDate.Rd 0000644 0001762 0000144 00000001365 14155600363 015765 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{convertToDate}
\alias{convertToDate}
\title{Convert from excel date number to R Date type}
\usage{
convertToDate(x, origin = "1900-01-01", ...)
}
\arguments{
\item{x}{A vector of integers}
\item{origin}{date. Default value is for Windows Excel 2010}
\item{...}{additional parameters passed to as.Date()}
}
\description{
Convert from excel date number to R Date type
}
\details{
Excel stores dates as number of days from some origin day
}
\examples{
## 2014 April 21st to 25th
convertToDate(c(41750, 41751, 41752, 41753, 41754, NA))
convertToDate(c(41750.2, 41751.99, NA, 41753))
}
\seealso{
\code{\link[=writeData]{writeData()}}
}
openxlsx/man/convertFromExcelRef.Rd 0000644 0001762 0000144 00000000763 14155600363 017127 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{convertFromExcelRef}
\alias{convertFromExcelRef}
\title{Convert excel column name to integer index}
\usage{
convertFromExcelRef(col)
}
\arguments{
\item{col}{An excel column reference}
}
\description{
Convert excel column name to integer index e.g. "J" to 10
}
\examples{
convertFromExcelRef("DOG")
convertFromExcelRef("COW")
## numbers will be removed
convertFromExcelRef("R22")
}
openxlsx/man/readWorkbook.Rd 0000644 0001762 0000144 00000005260 14155600363 015633 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/readWorkbook.R
\name{readWorkbook}
\alias{readWorkbook}
\title{Read from an Excel file or Workbook object}
\usage{
readWorkbook(
xlsxFile,
sheet = 1,
startRow = 1,
colNames = TRUE,
rowNames = FALSE,
detectDates = FALSE,
skipEmptyRows = TRUE,
skipEmptyCols = TRUE,
rows = NULL,
cols = NULL,
check.names = FALSE,
sep.names = ".",
namedRegion = NULL,
na.strings = "NA",
fillMergedCells = FALSE
)
}
\arguments{
\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.}
\item{sheet}{The name or index of the sheet to read data from.}
\item{startRow}{first row to begin looking for data. Empty rows at the top of a file are always skipped,
regardless of the value of startRow.}
\item{colNames}{If \code{TRUE}, the first row of data will be used as column names.}
\item{rowNames}{If \code{TRUE}, first column of data will be used as row names.}
\item{detectDates}{If \code{TRUE}, attempt to recognise dates and perform conversion.}
\item{skipEmptyRows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data
will return a row of NAs.}
\item{skipEmptyCols}{If \code{TRUE}, empty columns are skipped.}
\item{rows}{A numeric vector specifying which rows in the Excel file to read.
If NULL, all rows are read.}
\item{cols}{A numeric vector specifying which columns in the Excel file to read.
If NULL, all columns are read.}
\item{check.names}{logical. If TRUE then the names of the variables in the data frame
are checked to ensure that they are syntactically valid variable names}
\item{sep.names}{One character which substitutes blanks in column names. By default, "."}
\item{namedRegion}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.}
\item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.}
\item{fillMergedCells}{If TRUE, the value in a merged cell is given to all cells within the merge.}
}
\value{
data.frame
}
\description{
Read data from an Excel file or Workbook object into a data.frame
}
\details{
Creates a data.frame of all data in worksheet.
}
\examples{
xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx")
df1 <- readWorkbook(xlsxFile = xlsxFile, sheet = 1)
xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx")
df1 <- readWorkbook(xlsxFile = xlsxFile, sheet = 1, rows = c(1, 3, 5), cols = 1:3)
}
\seealso{
\code{\link[=getNamedRegions]{getNamedRegions()}}
\code{\link[=read.xlsx]{read.xlsx()}}
}
\author{
Alexander Walker
}
openxlsx/man/write.xlsx.Rd 0000644 0001762 0000144 00000012007 14155600364 015327 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/writexlsx.R
\name{write.xlsx}
\alias{write.xlsx}
\title{write data to an xlsx file}
\usage{
write.xlsx(x, file, asTable = FALSE, overwrite = TRUE, ...)
}
\arguments{
\item{x}{A data.frame or a (named) list of objects that can be handled by
\code{\link[=writeData]{writeData()}} or \code{\link[=writeDataTable]{writeDataTable()}} to write to file}
\item{file}{A file path to save the xlsx file}
\item{asTable}{If \code{TRUE} will use \code{\link[=writeDataTable]{writeDataTable()}} rather
than \code{\link[=writeData]{writeData()}} to write \code{x} to the file (default:
\code{FALSE})}
\item{overwrite}{Overwrite existing file (Defaults to \code{TRUE} as with \code{write.table})}
\item{...}{Additional arguments passed to \code{\link[=buildWorkbook]{buildWorkbook()}}; see details}
}
\value{
A workbook object
}
\description{
write a data.frame or list of data.frames to an xlsx file
}
\section{Optional Parameters}{
\strong{createWorkbook Parameters}
\itemize{
\item{\strong{creator}}{ A string specifying the workbook author}
}
\strong{addWorksheet Parameters}
\itemize{
\item{\strong{sheetName}}{ Name of the worksheet}
\item{\strong{gridLines}}{ A logical. If \code{FALSE}, the worksheet grid lines will be hidden.}
\item{\strong{tabColour}}{ Colour of the worksheet tab. A valid colour (belonging to colours())
or a valid hex colour beginning with "#".}
\item{\strong{zoom}}{ A numeric between 10 and 400. Worksheet zoom level as a percentage.}
}
\strong{writeData/writeDataTable Parameters}
\itemize{
\item{\strong{startCol}}{ A vector specifying the starting column(s) to write df}
\item{\strong{startRow}}{ A vector specifying the starting row(s) to write df}
\item{\strong{xy}}{ An alternative to specifying startCol and startRow individually.
A vector of the form c(startCol, startRow)}
\item{\strong{colNames or col.names}}{ If \code{TRUE}, column names of x are written.}
\item{\strong{rowNames or row.names}}{ If \code{TRUE}, row names of x are written.}
\item{\strong{headerStyle}}{ Custom style to apply to column names.}
\item{\strong{borders}}{ Either "surrounding", "columns" or "rows" or NULL. If "surrounding", a border is drawn around the
data. If "rows", a surrounding border is drawn a border around each row. If "columns", a surrounding border is drawn with a border
between each column. If "\code{all}" all cell borders are drawn.}
\item{\strong{borderColour}}{ Colour of cell border}
\item{\strong{borderStyle}}{ Border line style.}
\item{\strong{keepNA}} {If \code{TRUE}, NA values are converted to #N/A (or \code{na.string}, if not NULL) in Excel, else NA cells will be empty. Defaults to FALSE.}
\item{\strong{na.string}} {If not NULL, and if \code{keepNA} is \code{TRUE}, NA values are converted to this string in Excel. Defaults to NULL.}
}
\strong{freezePane Parameters}
\itemize{
\item{\strong{firstActiveRow}} {Top row of active region to freeze pane.}
\item{\strong{firstActiveCol}} {Furthest left column of active region to freeze pane.}
\item{\strong{firstRow}} {If \code{TRUE}, freezes the first row (equivalent to firstActiveRow = 2)}
\item{\strong{firstCol}} {If \code{TRUE}, freezes the first column (equivalent to firstActiveCol = 2)}
}
\strong{colWidths Parameters}
\itemize{
\item{\strong{colWidths}} {May be a single value for all columns (or "auto"), or a list of vectors that will be recycled for each sheet (see examples)}
}
}
\examples{
## write to working directory
options("openxlsx.borderColour" = "#4F80BD") ## set default border colour
\dontrun{
write.xlsx(iris, file = "writeXLSX1.xlsx", colNames = TRUE, borders = "columns")
write.xlsx(iris, file = "writeXLSX2.xlsx", colNames = TRUE, borders = "surrounding")
}
hs <- createStyle(
textDecoration = "BOLD", fontColour = "#FFFFFF", fontSize = 12,
fontName = "Arial Narrow", fgFill = "#4F80BD"
)
\dontrun{
write.xlsx(iris,
file = "writeXLSX3.xlsx",
colNames = TRUE, borders = "rows", headerStyle = hs
)
}
## Lists elements are written to individual worksheets, using list names as sheet names if available
l <- list("IRIS" = iris, "MTCATS" = mtcars, matrix(runif(1000), ncol = 5))
\dontrun{
write.xlsx(l, "writeList1.xlsx", colWidths = c(NA, "auto", "auto"))
}
## different sheets can be given different parameters
\dontrun{
write.xlsx(l, "writeList2.xlsx",
startCol = c(1, 2, 3), startRow = 2,
asTable = c(TRUE, TRUE, FALSE), withFilter = c(TRUE, FALSE, FALSE)
)
}
# specify column widths for multiple sheets
\dontrun{
write.xlsx(l, "writeList2.xlsx", colWidths = 20)
write.xlsx(l, "writeList2.xlsx", colWidths = list(100, 200, 300))
write.xlsx(l, "writeList2.xlsx", colWidths = list(rep(10, 5), rep(8, 11), rep(5, 5)))
}
}
\seealso{
\code{\link[=addWorksheet]{addWorksheet()}}
\code{\link[=writeData]{writeData()}}
\code{\link[=createStyle]{createStyle()}} for style parameters
\code{\link[=buildWorkbook]{buildWorkbook()}}
}
\author{
Alexander Walker, Jordan Mark Barbone
}
openxlsx/man/ungroupColumns.Rd 0000644 0001762 0000144 00000001067 14155600364 016244 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{ungroupColumns}
\alias{ungroupColumns}
\title{Ungroup Columns}
\usage{
ungroupColumns(wb, sheet, cols)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{Indices of columns to ungroup}
}
\description{
Ungroup a selection of columns
}
\details{
If column was previously hidden, it will now be shown
}
\seealso{
\code{\link[=ungroupRows]{ungroupRows()}} To ungroup rows
}
\author{
Joshua Sturm
}
openxlsx/man/removeCellMerge.Rd 0000644 0001762 0000144 00000001156 14155600363 016257 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{removeCellMerge}
\alias{removeCellMerge}
\title{Create a new Workbook object}
\usage{
removeCellMerge(wb, sheet, cols, rows)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{vector of column indices}
\item{rows}{vector of row indices}
}
\description{
Unmerges any merged cells that intersect
with the region specified by, min(cols):max(cols) X min(rows):max(rows)
}
\seealso{
\code{\link[=mergeCells]{mergeCells()}}
}
\author{
Alexander Walker
}
openxlsx/man/setHeader.Rd 0000644 0001762 0000144 00000002025 14155600364 015103 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{setHeader}
\alias{setHeader}
\title{Set header for all worksheets}
\usage{
setHeader(wb, text, position = "center")
}
\arguments{
\item{wb}{A workbook object}
\item{text}{header text. A character vector of length 1.}
\item{position}{Position of text in header. One of "left", "center" or "right"}
}
\description{
DEPRECATED
}
\examples{
\dontrun{
wb <- createWorkbook("Edgar Anderson")
addWorksheet(wb, "S1")
writeDataTable(wb, "S1", x = iris[1:30, ], xy = c("C", 5))
## set all headers
setHeader(wb, "This is a header", position = "center")
setHeader(wb, "To the left", position = "left")
setHeader(wb, "On the right", position = "right")
## set all footers
setFooter(wb, "Center Footer Here", position = "center")
setFooter(wb, "Bottom left", position = "left")
setFooter(wb, Sys.Date(), position = "right")
saveWorkbook(wb, "headerHeaderExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker
}
openxlsx/man/conditionalFormat.Rd 0000644 0001762 0000144 00000002526 14155600363 016660 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{conditionalFormat}
\alias{conditionalFormat}
\title{Add conditional formatting to cells}
\usage{
conditionalFormat(
wb,
sheet,
cols,
rows,
rule = NULL,
style = NULL,
type = "expression"
)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{Columns to apply conditional formatting to}
\item{rows}{Rows to apply conditional formatting to}
\item{rule}{The condition under which to apply the formatting or a vector of colours. See examples.}
\item{style}{A style to apply to those cells that satisfy the rule. A Style object returned from createStyle()}
\item{type}{Either 'expression', 'colorscale' or 'databar'. If 'expression' the formatting is determined
by a formula. If colorScale cells are coloured based on cell value. See examples.}
}
\description{
DEPRECATED! USE \code{\link[=conditionalFormatting]{conditionalFormatting()}}
}
\details{
DEPRECATED! USE \code{\link[=conditionalFormatting]{conditionalFormatting()}}
Valid operators are "<", "<=", ">", ">=", "==", "!=". See Examples.
Default style given by: createStyle(fontColour = "#9C0006", bgFill = "#FFC7CE")
}
\seealso{
\code{\link[=createStyle]{createStyle()}}
}
\author{
Alexander Walker
}
openxlsx/man/temp_xlsx.Rd 0000644 0001762 0000144 00000000564 14155600364 015230 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{temp_xlsx}
\alias{temp_xlsx}
\title{helper function to create tempory directory for testing purpose}
\usage{
temp_xlsx(name = "temp_xlsx")
}
\arguments{
\item{name}{for the temp file}
}
\description{
helper function to create tempory directory for testing purpose
}
openxlsx/man/pageSetup.Rd 0000644 0001762 0000144 00000014544 14155600363 015144 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{pageSetup}
\alias{pageSetup}
\title{Set page margins, orientation and print scaling}
\usage{
pageSetup(
wb,
sheet,
orientation = NULL,
scale = 100,
left = 0.7,
right = 0.7,
top = 0.75,
bottom = 0.75,
header = 0.3,
footer = 0.3,
fitToWidth = FALSE,
fitToHeight = FALSE,
paperSize = NULL,
printTitleRows = NULL,
printTitleCols = NULL,
summaryRow = NULL,
summaryCol = NULL
)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{orientation}{Page orientation. One of "portrait" or "landscape"}
\item{scale}{Print scaling. Numeric value between 10 and 400}
\item{left}{left page margin in inches}
\item{right}{right page margin in inches}
\item{top}{top page margin in inches}
\item{bottom}{bottom page margin in inches}
\item{header}{header margin in inches}
\item{footer}{footer margin in inches}
\item{fitToWidth}{If \code{TRUE}, worksheet is scaled to fit to page width on printing.}
\item{fitToHeight}{If \code{TRUE}, worksheet is scaled to fit to page height on printing.}
\item{paperSize}{See details. Default value is 9 (A4 paper).}
\item{printTitleRows}{Rows to repeat at top of page when printing. Integer vector.}
\item{printTitleCols}{Columns to repeat at left when printing. Integer vector.}
\item{summaryRow}{Location of summary rows in groupings. One of "Above" or "Below".}
\item{summaryCol}{Location of summary columns in groupings. One of "Right" or "Left".}
}
\description{
Set page margins, orientation and print scaling
}
\details{
paperSize is an integer corresponding to:
\itemize{
\item{\strong{1}}{ Letter paper (8.5 in. by 11 in.)}
\item{\strong{2}}{ Letter small paper (8.5 in. by 11 in.)}
\item{\strong{3}}{ Tabloid paper (11 in. by 17 in.)}
\item{\strong{4}}{ Ledger paper (17 in. by 11 in.)}
\item{\strong{5}}{ Legal paper (8.5 in. by 14 in.)}
\item{\strong{6}}{ Statement paper (5.5 in. by 8.5 in.)}
\item{\strong{7}}{ Executive paper (7.25 in. by 10.5 in.)}
\item{\strong{8}}{ A3 paper (297 mm by 420 mm)}
\item{\strong{9}}{ A4 paper (210 mm by 297 mm)}
\item{\strong{10}}{ A4 small paper (210 mm by 297 mm)}
\item{\strong{11}}{ A5 paper (148 mm by 210 mm)}
\item{\strong{12}}{ B4 paper (250 mm by 353 mm)}
\item{\strong{13}}{ B5 paper (176 mm by 250 mm)}
\item{\strong{14}}{ Folio paper (8.5 in. by 13 in.)}
\item{\strong{15}}{ Quarto paper (215 mm by 275 mm)}
\item{\strong{16}}{ Standard paper (10 in. by 14 in.)}
\item{\strong{17}}{ Standard paper (11 in. by 17 in.)}
\item{\strong{18}}{ Note paper (8.5 in. by 11 in.)}
\item{\strong{19}}{ #9 envelope (3.875 in. by 8.875 in.)}
\item{\strong{20}}{ #10 envelope (4.125 in. by 9.5 in.)}
\item{\strong{21}}{ #11 envelope (4.5 in. by 10.375 in.)}
\item{\strong{22}}{ #12 envelope (4.75 in. by 11 in.)}
\item{\strong{23}}{ #14 envelope (5 in. by 11.5 in.)}
\item{\strong{24}}{ C paper (17 in. by 22 in.)}
\item{\strong{25}}{ D paper (22 in. by 34 in.)}
\item{\strong{26}}{ E paper (34 in. by 44 in.)}
\item{\strong{27}}{ DL envelope (110 mm by 220 mm)}
\item{\strong{28}}{ C5 envelope (162 mm by 229 mm)}
\item{\strong{29}}{ C3 envelope (324 mm by 458 mm)}
\item{\strong{30}}{ C4 envelope (229 mm by 324 mm)}
\item{\strong{31}}{ C6 envelope (114 mm by 162 mm)}
\item{\strong{32}}{ C65 envelope (114 mm by 229 mm)}
\item{\strong{33}}{ B4 envelope (250 mm by 353 mm)}
\item{\strong{34}}{ B5 envelope (176 mm by 250 mm)}
\item{\strong{35}}{ B6 envelope (176 mm by 125 mm)}
\item{\strong{36}}{ Italy envelope (110 mm by 230 mm)}
\item{\strong{37}}{ Monarch envelope (3.875 in. by 7.5 in.).}
\item{\strong{38}}{ 6 3/4 envelope (3.625 in. by 6.5 in.)}
\item{\strong{39}}{ US standard fanfold (14.875 in. by 11 in.)}
\item{\strong{40}}{ German standard fanfold (8.5 in. by 12 in.)}
\item{\strong{41}}{ German legal fanfold (8.5 in. by 13 in.)}
\item{\strong{42}}{ ISO B4 (250 mm by 353 mm)}
\item{\strong{43}}{ Japanese double postcard (200 mm by 148 mm)}
\item{\strong{44}}{ Standard paper (9 in. by 11 in.)}
\item{\strong{45}}{ Standard paper (10 in. by 11 in.)}
\item{\strong{46}}{ Standard paper (15 in. by 11 in.)}
\item{\strong{47}}{ Invite envelope (220 mm by 220 mm)}
\item{\strong{50}}{ Letter extra paper (9.275 in. by 12 in.)}
\item{\strong{51}}{ Legal extra paper (9.275 in. by 15 in.)}
\item{\strong{52}}{ Tabloid extra paper (11.69 in. by 18 in.)}
\item{\strong{53}}{ A4 extra paper (236 mm by 322 mm)}
\item{\strong{54}}{ Letter transverse paper (8.275 in. by 11 in.)}
\item{\strong{55}}{ A4 transverse paper (210 mm by 297 mm)}
\item{\strong{56}}{ Letter extra transverse paper (9.275 in. by 12 in.)}
\item{\strong{57}}{ SuperA/SuperA/A4 paper (227 mm by 356 mm)}
\item{\strong{58}}{ SuperB/SuperB/A3 paper (305 mm by 487 mm)}
\item{\strong{59}}{ Letter plus paper (8.5 in. by 12.69 in.)}
\item{\strong{60}}{ A4 plus paper (210 mm by 330 mm)}
\item{\strong{61}}{ A5 transverse paper (148 mm by 210 mm)}
\item{\strong{62}}{ JIS B5 transverse paper (182 mm by 257 mm)}
\item{\strong{63}}{ A3 extra paper (322 mm by 445 mm)}
\item{\strong{64}}{ A5 extra paper (174 mm by 235 mm)}
\item{\strong{65}}{ ISO B5 extra paper (201 mm by 276 mm)}
\item{\strong{66}}{ A2 paper (420 mm by 594 mm)}
\item{\strong{67}}{ A3 transverse paper (297 mm by 420 mm)}
\item{\strong{68}}{ A3 extra transverse paper (322 mm by 445 mm)}
}
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "S1")
addWorksheet(wb, "S2")
writeDataTable(wb, 1, x = iris[1:30, ])
writeDataTable(wb, 2, x = iris[1:30, ], xy = c("C", 5))
## landscape page scaled to 50\%
pageSetup(wb, sheet = 1, orientation = "landscape", scale = 50)
## portrait page scales to 300\% with 0.5in left and right margins
pageSetup(wb, sheet = 2, orientation = "portrait", scale = 300, left = 0.5, right = 0.5)
## print titles
addWorksheet(wb, "print_title_rows")
addWorksheet(wb, "print_title_cols")
writeData(wb, "print_title_rows", rbind(iris, iris, iris, iris))
writeData(wb, "print_title_cols", x = rbind(mtcars, mtcars, mtcars), rowNames = TRUE)
pageSetup(wb, sheet = "print_title_rows", printTitleRows = 1) ## first row
pageSetup(wb, sheet = "print_title_cols", printTitleCols = 1, printTitleRows = 1)
\dontrun{
saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker, Joshua Sturm
}
openxlsx/man/addStyle.Rd 0000644 0001762 0000144 00000003365 14155600363 014757 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{addStyle}
\alias{addStyle}
\title{Add a style to a set of cells}
\usage{
addStyle(wb, sheet, style, rows, cols, gridExpand = FALSE, stack = FALSE)
}
\arguments{
\item{wb}{A Workbook object containing a worksheet.}
\item{sheet}{A worksheet to apply the style to.}
\item{style}{A style object returned from createStyle()}
\item{rows}{Rows to apply style to.}
\item{cols}{columns to apply style to.}
\item{gridExpand}{If \code{TRUE}, style will be applied to all combinations of rows and cols.}
\item{stack}{If \code{TRUE} the new style is merged with any existing cell styles. If FALSE, any
existing style is replaced by the new style.}
}
\description{
Function adds a style to a specified set of cells.
}
\examples{
## See package vignette for more examples.
## Create a new workbook
wb <- createWorkbook("My name here")
## Add a worksheets
addWorksheet(wb, "Expenditure", gridLines = FALSE)
## write data to worksheet 1
writeData(wb, sheet = 1, USPersonalExpenditure, rowNames = TRUE)
## create and add a style to the column headers
headerStyle <- createStyle(
fontSize = 14, fontColour = "#FFFFFF", halign = "center",
fgFill = "#4F81BD", border = "TopBottom", borderColour = "#4F81BD"
)
## style for body
bodyStyle <- createStyle(border = "TopBottom", borderColour = "#4F81BD")
addStyle(wb, sheet = 1, bodyStyle, rows = 2:6, cols = 1:6, gridExpand = TRUE)
setColWidths(wb, 1, cols = 1, widths = 21) ## set column width for row names column
\dontrun{
saveWorkbook(wb, "addStyleExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=createStyle]{createStyle()}}
expand.grid
}
\author{
Alexander Walker
}
openxlsx/man/NamedRegion.Rd 0000644 0001762 0000144 00000003422 14155600363 015370 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{createNamedRegion}
\alias{createNamedRegion}
\alias{deleteNamedRegion}
\title{Create / delete a named region.}
\usage{
createNamedRegion(wb, sheet, cols, rows, name, overwrite = FALSE)
deleteNamedRegion(wb, name)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{Numeric vector specifying columns to include in region}
\item{rows}{Numeric vector specifying rows to include in region}
\item{name}{Name for region. A character vector of length 1. Note region names musts be case-insensitive unique.}
\item{overwrite}{Boolean. Overwrite if exists ? Default to FALSE}
}
\description{
Create / delete a named region
}
\details{
Region is given by: min(cols):max(cols) X min(rows):max(rows)
}
\examples{
## create named regions
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
## specify region
writeData(wb, sheet = 1, x = iris, startCol = 1, startRow = 1)
createNamedRegion(
wb = wb,
sheet = 1,
name = "iris",
rows = 1:(nrow(iris) + 1),
cols = 1:ncol(iris)
)
## using writeData 'name' argument
writeData(wb, sheet = 1, x = iris, name = "iris2", startCol = 10)
out_file <- tempfile(fileext = ".xlsx")
\dontrun{
saveWorkbook(wb, out_file, overwrite = TRUE)
## see named regions
getNamedRegions(wb) ## From Workbook object
getNamedRegions(out_file) ## From xlsx file
## delete one
deleteNamedRegion(wb = wb, name = "iris2")
getNamedRegions(wb)
## read named regions
df <- read.xlsx(wb, namedRegion = "iris")
head(df)
df <- read.xlsx(out_file, namedRegion = "iris2")
head(df)
}
}
\seealso{
\code{\link[=getNamedRegions]{getNamedRegions()}}
}
\author{
Alexander Walker
}
openxlsx/man/setFooter.Rd 0000644 0001762 0000144 00000002025 14155600364 015151 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{setFooter}
\alias{setFooter}
\title{Set footer for all worksheets}
\usage{
setFooter(wb, text, position = "center")
}
\arguments{
\item{wb}{A workbook object}
\item{text}{footer text. A character vector of length 1.}
\item{position}{Position of text in footer. One of "left", "center" or "right"}
}
\description{
DEPRECATED
}
\examples{
\dontrun{
wb <- createWorkbook("Edgar Anderson")
addWorksheet(wb, "S1")
writeDataTable(wb, "S1", x = iris[1:30, ], xy = c("C", 5))
## set all headers
setHeader(wb, "This is a header", position = "center")
setHeader(wb, "To the left", position = "left")
setHeader(wb, "On the right", position = "right")
## set all footers
setFooter(wb, "Center Footer Here", position = "center")
setFooter(wb, "Bottom left", position = "left")
setFooter(wb, Sys.Date(), position = "right")
saveWorkbook(wb, "headerFooterExample.xlsx", overwrite = TRUE)
}
}
\author{
Alexander Walker
}
openxlsx/man/pageBreak.Rd 0000644 0001762 0000144 00000001626 14155600363 015065 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{pageBreak}
\alias{pageBreak}
\title{add a page break to a worksheet}
\usage{
pageBreak(wb, sheet, i, type = "row")
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{i}{row or column number to insert page break.}
\item{type}{One of "row" or "column" for a row break or column break.}
}
\description{
insert page breaks into a worksheet
}
\examples{
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
writeData(wb, sheet = 1, x = iris)
pageBreak(wb, sheet = 1, i = 10, type = "row")
pageBreak(wb, sheet = 1, i = 20, type = "row")
pageBreak(wb, sheet = 1, i = 2, type = "column")
\dontrun{
saveWorkbook(wb, "pageBreakExample.xlsx", TRUE)
}
## In Excel: View tab -> Page Break Preview
}
\seealso{
\code{\link[=addWorksheet]{addWorksheet()}}
}
openxlsx/man/getNamedRegions.Rd 0000644 0001762 0000144 00000002261 14155600363 016253 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{getNamedRegions}
\alias{getNamedRegions}
\title{Get named regions}
\usage{
getNamedRegions(x)
}
\arguments{
\item{x}{An xlsx file or Workbook object}
}
\description{
Return a vector of named regions in a xlsx file or
Workbook object
}
\examples{
## create named regions
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
## specify region
writeData(wb, sheet = 1, x = iris, startCol = 1, startRow = 1)
createNamedRegion(
wb = wb,
sheet = 1,
name = "iris",
rows = 1:(nrow(iris) + 1),
cols = 1:ncol(iris)
)
## using writeData 'name' argument to create a named region
writeData(wb, sheet = 1, x = iris, name = "iris2", startCol = 10)
\dontrun{
out_file <- tempfile(fileext = ".xlsx")
saveWorkbook(wb, out_file, overwrite = TRUE)
## see named regions
getNamedRegions(wb) ## From Workbook object
getNamedRegions(out_file) ## From xlsx file
## read named regions
df <- read.xlsx(wb, namedRegion = "iris")
head(df)
df <- read.xlsx(out_file, namedRegion = "iris2")
head(df)
}
}
\seealso{
\code{\link[=createNamedRegion]{createNamedRegion()}}
}
openxlsx/man/groupRows.Rd 0000644 0001762 0000144 00000001203 14155600363 015202 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{groupRows}
\alias{groupRows}
\title{Group Rows}
\usage{
groupRows(wb, sheet, rows, hidden = FALSE)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{rows}{Indices of rows to group}
\item{hidden}{Logical vector. If TRUE the grouped columns are hidden. Defaults to FALSE}
}
\description{
Group a selection of rows
}
\seealso{
\code{\link[=ungroupRows]{ungroupRows()}} to ungroup rows. \code{\link[=groupColumns]{groupColumns()}} for grouping columns.
}
\author{
Joshua Sturm
}
openxlsx/man/figures/ 0000755 0001762 0000144 00000000000 14155600363 014354 5 ustar ligges users openxlsx/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000001704 14155600363 020464 0 ustar ligges users