Commit 63ffa4b
Phase 3: page setup and printing (#121)
* Add xl_page_setup() with the scalar print options
xl_sheet(page =) takes an xl_page_setup() describing how the sheet prints:
orientation, paper size, margins, scaling, fit-to-pages, centring, starting
page number, page-layout view, and the print options (across, black and white,
row and column headings). None of it touches the cells.
paper accepts friendly names mapped to Excel's numeric types, and a raw index
for the envelope and specialist sizes not worth naming; the range is capped at
libxlsxwriter's real 0-118, since outside it worksheet_set_paper() warns and
ignores the value, which from R would be a silent no-op.
worksheet_set_start_page() is the one setter in libxlsxwriter that does not
raise page_setup_changed, so a first_page on its own emitted no <pageSetup>
element and was silently dropped. worksheet_set_paper() does raise it, and
paper size 0 writes no attribute, so it is called alongside first_page as a
harmless way to mark the sheet as having a page setup.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Add page headers and footers
xl_page_setup() gains header, footer, header_margin and footer_margin, reaching
worksheet_set_header/_opt and worksheet_set_footer/_opt. Excel's own &-codes
are passed through untouched; the plain setter is used when no margin is given
and the _opt form only when one is.
Two libxlsxwriter behaviours are surfaced in R rather than left to fail
obscurely. A margin is applied only when greater than zero, so a zero would be
silently ignored and is now an error naming Excel's 0.3 default. An &G or
&[Picture] placeholder needs a matching image, which writexl cannot supply
until images land, so it is rejected with a message that says so instead of
libxlsxwriter's opaque parameter-validation error.
The 255-character cap is enforced in R, counting characters rather than bytes
as lxw_utf8_strlen() does.
Header and footer images are deliberately deferred: lxw_header_footer_options
carries image_left/center/right, and those belong with the rest of the image
handling rather than being built twice.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Add print area, repeat rows/columns, and page breaks
xl_page_setup() gains print_area, repeat_rows, repeat_cols, h_breaks and
v_breaks, completing the page-setup surface.
print_area goes through the Phase 0 range resolver, so it takes an A1 string or
a list(rows =, cols =) spec like every other range argument. repeat_rows and
repeat_cols take either a count or a range string, and count *sheet* rows with
the header included rather than data rows -- repeating the header row is the
usual reason to reach for them, and data-row numbering could not name it.
Page breaks are given as 1-based positions where a new page starts, matching
how Excel describes them, and converted to libxlsxwriter's 0-based form. A
break at position 1 is refused: libxlsxwriter terminates its break array with a
0, so a 0-based break of 0 would silently discard every break rather than
merely doing nothing. Breaks are sorted and deduplicated, and capped at Excel's
limit of 1023. Setting breaks together with fit_to warns, since Excel ignores
manual breaks when fit-to-page is on.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Document page setup in the vignette and NEWS
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent d9af39d commit 63ffa4b
22 files changed
Lines changed: 1062 additions & 4 deletions
File tree
- R
- man
- src
- tests/testthat
- vignettes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| |||
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | | - | |
| 164 | + | |
| 165 | + | |
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
| |||
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
187 | | - | |
| 191 | + | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
| |||
368 | 373 | | |
369 | 374 | | |
370 | 375 | | |
| 376 | + | |
371 | 377 | | |
372 | 378 | | |
373 | 379 | | |
| |||
410 | 416 | | |
411 | 417 | | |
412 | 418 | | |
| 419 | + | |
413 | 420 | | |
414 | 421 | | |
415 | 422 | | |
| |||
435 | 442 | | |
436 | 443 | | |
437 | 444 | | |
438 | | - | |
| 445 | + | |
| 446 | + | |
439 | 447 | | |
440 | 448 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments