1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{setColWidths}
\alias{setColWidths}
\title{Set worksheet column widths}
\usage{
setColWidths(
wb,
sheet,
cols,
widths = 8.43,
hidden = rep(FALSE, length(cols)),
ignoreMergedCells = FALSE
)
}
\arguments{
\item{wb}{A workbook object}
\item{sheet}{A name or index of a worksheet}
\item{cols}{Indices of cols to set width}
\item{widths}{widths to set cols to specified in Excel column width units or "auto" for automatic sizing. The widths argument is
recycled to the length of cols.}
\item{hidden}{Logical vector. If TRUE the column is hidden.}
\item{ignoreMergedCells}{Ignore any cells that have been merged with other cells in the calculation of "auto" column widths.}
}
\description{
Set worksheet column widths to specific width or "auto".
}
\details{
The global min and max column width for "auto" columns is set by (default values show):
\itemize{
\item{options("openxlsx.minWidth" = 3)}
\item{options("openxlsx.maxWidth" = 250)} ## This is the maximum width allowed in Excel
}
NOTE: The calculation of column widths can be slow for large worksheets.
NOTE: The \code{hidden} parameter may conflict with the one set in \code{groupColumns}; changing one will update the other.
}
\examples{
## Create a new workbook
wb <- createWorkbook()
## Add a worksheet
addWorksheet(wb, "Sheet 1")
## set col widths
setColWidths(wb, 1, cols = c(1, 4, 6, 7, 9), widths = c(16, 15, 12, 18, 33))
## auto columns
addWorksheet(wb, "Sheet 2")
writeData(wb, sheet = 2, x = iris)
setColWidths(wb, sheet = 2, cols = 1:5, widths = "auto")
## Save workbook
\dontrun{
saveWorkbook(wb, "setColWidthsExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=removeColWidths]{removeColWidths()}}
}
\author{
Alexander Walker
}
|