Learn R Programming

openxlsx (version 1.0.3)

pageSetup: Set page margins, orientation and print scaling

Description

Set page margins, orientation and print scaling

Usage

pageSetup(wb, sheet, orientation = "portrait", scale = 100, left = 0.7,
  right = 0.7, top = 0.75, bottom = 0.75, header = 0.3, footer = 0.3)

Arguments

wb
A workbook object
sheet
A name or index of a worksheet
orientation
Page orientation. One of "portrait" or "landscape"
scale
Print scaling. Numeric value between 10 and 400
left
left page margin in inches
right
right page margin in inches
top
top page margin in inches
bottom
bottom page margin in inches
header
header margin in inches
footer
footer margin in inches

Examples

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

saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)

Run the code above in your browser using DataLab