The wb_add_page_break() function allows you to manually insert horizontal
or vertical page breaks into a worksheet. These breaks determine where the
spreadsheet software starts a new page when printing or generating a PDF.
Usage
wb_add_page_break(wb, sheet = current_sheet(), row = NULL, col = NULL)Arguments
- wb
A wbWorkbook object.
- sheet
The name or index of the worksheet. Defaults to the current sheet.
- row
Integer; the row number where the horizontal page break should be inserted.
- col
Integer or character; the column number or name (e.g., "B") where the vertical page break should be inserted.
Value
The wbWorkbook object, invisibly.
Details
Manual page breaks override the automatic breaks calculated by the software based on margins and paper size.
Row Breaks: When a
rowis specified, the horizontal break is placed above the specified row. For example, settingrow = 10ensures that Row 10 starts on a new page.Column Breaks: When a
colis specified, the vertical break is placed to the left of that column. For example,col = "B"(or2) ensures Column B is the first column on the next vertical page.
You must provide either a row or a col index, but not both in a single
call. To create a page intersection (both horizontal and vertical), call
the function twice.
Examples
wb <- wb_workbook()
wb$add_worksheet("Sheet 1")
wb$add_data(sheet = 1, x = iris)
wb$add_page_break(sheet = 1, row = 10)
wb$add_page_break(sheet = 1, row = 20)
wb$add_page_break(sheet = 1, col = 2)
