pageSetup: Set page margins, orientation and print scaling

Description Usage Arguments Details Author(s) Examples

Description

Set page margins, orientation and print scaling

Usage

1
2
3
4
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)

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

fitToWidth

If TRUE, worksheet is scaled to fit to page width on printing.

fitToHeight

If TRUE, worksheet is scaled to fit to page height on printing.

paperSize

See details. Default value is 9 (A4 paper).

printTitleRows

Rows to repeat at top of page when printing. Integer vector.

printTitleCols

Columns to repeat at left when printing. Integer vector.

Details

paperSize is an integer corresponding to:

Author(s)

Alexander Walker

Examples

 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
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)


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

awalker89/openxlsx documentation built on May 11, 2019, 4:09 p.m.