Set page margins, orientation and print scaling
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
)
A workbook object
A name or index of a worksheet
Page orientation. One of "portrait" or "landscape"
Print scaling. Numeric value between 10 and 400
left page margin in inches
right page margin in inches
top page margin in inches
bottom page margin in inches
header margin in inches
footer margin in inches
If TRUE
, worksheet is scaled to fit to page width on printing.
If TRUE
, worksheet is scaled to fit to page height on printing.
See details. Default value is 9 (A4 paper).
Rows to repeat at top of page when printing. Integer vector.
Columns to repeat at left when printing. Integer vector.
Location of summary rows in groupings. One of "Above" or "Below".
Location of summary columns in groupings. One of "Right" or "Left".
paperSize is an integer corresponding to:
Letter paper (8.5 in. by 11 in.)
Letter small paper (8.5 in. by 11 in.)
Tabloid paper (11 in. by 17 in.)
Ledger paper (17 in. by 11 in.)
Legal paper (8.5 in. by 14 in.)
Statement paper (5.5 in. by 8.5 in.)
Executive paper (7.25 in. by 10.5 in.)
A3 paper (297 mm by 420 mm)
A4 paper (210 mm by 297 mm)
A4 small paper (210 mm by 297 mm)
A5 paper (148 mm by 210 mm)
B4 paper (250 mm by 353 mm)
B5 paper (176 mm by 250 mm)
Folio paper (8.5 in. by 13 in.)
Quarto paper (215 mm by 275 mm)
Standard paper (10 in. by 14 in.)
Standard paper (11 in. by 17 in.)
Note paper (8.5 in. by 11 in.)
#9 envelope (3.875 in. by 8.875 in.)
#10 envelope (4.125 in. by 9.5 in.)
#11 envelope (4.5 in. by 10.375 in.)
#12 envelope (4.75 in. by 11 in.)
#14 envelope (5 in. by 11.5 in.)
C paper (17 in. by 22 in.)
D paper (22 in. by 34 in.)
E paper (34 in. by 44 in.)
DL envelope (110 mm by 220 mm)
C5 envelope (162 mm by 229 mm)
C3 envelope (324 mm by 458 mm)
C4 envelope (229 mm by 324 mm)
C6 envelope (114 mm by 162 mm)
C65 envelope (114 mm by 229 mm)
B4 envelope (250 mm by 353 mm)
B5 envelope (176 mm by 250 mm)
B6 envelope (176 mm by 125 mm)
Italy envelope (110 mm by 230 mm)
Monarch envelope (3.875 in. by 7.5 in.).
6 3/4 envelope (3.625 in. by 6.5 in.)
US standard fanfold (14.875 in. by 11 in.)
German standard fanfold (8.5 in. by 12 in.)
German legal fanfold (8.5 in. by 13 in.)
ISO B4 (250 mm by 353 mm)
Japanese double postcard (200 mm by 148 mm)
Standard paper (9 in. by 11 in.)
Standard paper (10 in. by 11 in.)
Standard paper (15 in. by 11 in.)
Invite envelope (220 mm by 220 mm)
Letter extra paper (9.275 in. by 12 in.)
Legal extra paper (9.275 in. by 15 in.)
Tabloid extra paper (11.69 in. by 18 in.)
A4 extra paper (236 mm by 322 mm)
Letter transverse paper (8.275 in. by 11 in.)
A4 transverse paper (210 mm by 297 mm)
Letter extra transverse paper (9.275 in. by 12 in.)
SuperA/SuperA/A4 paper (227 mm by 356 mm)
SuperB/SuperB/A3 paper (305 mm by 487 mm)
Letter plus paper (8.5 in. by 12.69 in.)
A4 plus paper (210 mm by 330 mm)
A5 transverse paper (148 mm by 210 mm)
JIS B5 transverse paper (182 mm by 257 mm)
A3 extra paper (322 mm by 445 mm)
A5 extra paper (174 mm by 235 mm)
ISO B5 extra paper (201 mm by 276 mm)
A2 paper (420 mm by 594 mm)
A3 transverse paper (297 mm by 420 mm)
A3 extra transverse paper (322 mm by 445 mm)
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)
if (FALSE) { # \dontrun{
saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)
} # }