From 22cfc96ca5ab504076e6d688033ea7eea87e1d82 Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Mon, 2 Oct 2023 22:09:26 +0200 Subject: [PATCH] add hack for media references --- R/class-workbook.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R/class-workbook.R b/R/class-workbook.R index 6dff49a5a..42858fcb5 100644 --- a/R/class-workbook.R +++ b/R/class-workbook.R @@ -1080,6 +1080,18 @@ wbWorkbook <- R6::R6Class( # - Slicers if (external_wb) { + + # FIXME we copy all references from a workbook over to this workbook. + # This is not going to work, if multiple images from different + # workbooks are used. The references are called imageX.jpg and will + # overwrite each other. This needs a better solution + if (length(from$media)) { + if (!any(grepl("Default Extension=\"jpg\"", self$Content_Types))) { + self$append("Content_Types", "") + } + self$media <- append(self$media, from$media) + } + # update sheet styles style <- get_cellstyle(from, sheet = old) # only if styles are present