openxlsx2
openxlsx2 copied to clipboard
consider header/footer specs `hf_spec()`
probably would be better to do something like :
hf_spec <- function(type = c("header", "footer"), default = NULL, odd = default, even = default, first = default, last = default) {
type <- match.arg(type)
...
structure(ls, class = "header_footer_spec")
}
# fun printing
print.header_footer_spec <- function(x, ...) {
...
invisible(x)
}
And handle the header and footer separately. Would be easy then to toggle:
# even only:
hf_spec("header", odd = "odd_header_here")
# skip first page:
hf_spec("header", "default_spec_here", first = NULL)
... and etc, etc.
- make it easy to set header and footer text
- consider ability to use an image (e.g. company logo) (perhaps something like
hf_spec("header", "{image1} Header text {image2}", images = list(image1 = filepath1.png, image2 = filepath2.png))
? But I don't really know how this is done with the xml
I quickly drafted an example and had a look at the xml: logo_hf.xlsx
<headerFooter>
<!-- left header: P is current Page, N is number of pages -->
<!-- center header: current date and time 2022-03-13 00:04 CET in dd.mm.yy hh:mm notation -->
<!-- right header: the graphic rId1 -->
<oddHeader>&L&P/&N&C&"System Font,Regular"&10&K000000&D &T&R&G</oddHeader>
</headerFooter>
<legacyDrawingHF r:id="rId1"/>
Needs the following (should all be copyable from insertImage
)
- content_types entries: png,
- media
- vmlDrawing
- vmlDrawing_rel pointing to media
- legacy drawing entry in worksheet
- worksheet_rel entry pointing to vml_drawing
Guess we can use all of the insertImage
code, but instead of adding it somewhere in the worksheet, we add it to the header. But that's as far I am about to go with this issue 😄
[Edit] "Only one picture can be inserted in each section of the header."
ofc duplication should be minimised, maybe we can simply extract the media to workbook part and make the include image to worksheet/header part special cases