Learn R Programming

openxlsx (version 2.0.1)

setColWidths: Set worksheet column widths

Description

Set worksheet column widths

Usage

setColWidths(wb, sheet, cols, widths)

Arguments

wb
A workbook object
sheet
A name or index of a worksheet
cols
Indices of cols to set width
widths
widths to set rows to specified in Excel column width units.

See Also

removeColWidths

Examples

Run this code
## 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))

## Save workbook
saveWorkbook(wb, "setColWidthsExample.xlsx", overwrite = TRUE)

Run the code above in your browser using DataLab