You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using devEMF::emf() to create emf files. When inserting these files using addImage(), the cell of the resulting xlsx file remains blank. When I insert the same file by using "Insert -> Image" in Microsoft Excel, the image is displayed fine so the problem, presumably, is not with the created emf file itself.
I have tested different parameter configurations for devEMF::emf() (e.g. setting emfPLUS = FALSE), to no effect.
Unfortunately, I do not have access to emf files NOT created by devEMF::emf(), so I could not test whether the problem exists for all emf files in general, or only for the ones created by devEMF.
Using other devices / image formats (such as png) with the code below worked with no problems.
I have also looked at other packages, such as openxlsx::insertImage(), but that function does not support emf files in the first place.
It would be fantastic to get this working somehow. I have used devEMF::emf() extensively for R Markdown and Word documents, with great results, so I am very interested in getting this to work for Excel as well.
library(devEMF)
library(XLConnect)
#> Warning: package 'XLConnect' was built under R version 4.1.3#> XLConnect 1.0.5 by Mirai Solutions GmbH [aut],#> Martin Studer [cre],#> The Apache Software Foundation [ctb, cph] (Apache POI),#> Graph Builder [ctb, cph] (Curvesapi Java library),#> Brett Woolridge [ctb, cph] (SparseBitSet Java library)#> https://mirai-solutions.ch#> https://github.com/miraisolutions/xlconnectwb<- loadWorkbook("devEMF.xlsx", create=TRUE)
createSheet(wb, name="devEMF")
createName(wb, name="devEMF_plot", formula="devEMF!$A$1")
devEMF::emf(file="plot_test.emf")
plot(1,1)
dev.off()
#> png #> 2
addImage(wb, filename="plot_test.emf", name="devEMF_plot",
originalSize=TRUE)
saveWorkbook(wb)
After posting this issue, I realized I had not tested setting originalSize = FALSE. Running the example above with originalSize = FALSE leads to an image being displayed.
So the issue seems to be the combination of emf files with the parameter originalSize = TRUE.
My aim is to insert the image with width and height scaled to 100% of the dimensions specified by the graphics device.
I am using
devEMF::emf()
to create emf files. When inserting these files usingaddImage()
, the cell of the resulting xlsx file remains blank. When I insert the same file by using "Insert -> Image" in Microsoft Excel, the image is displayed fine so the problem, presumably, is not with the created emf file itself.I have tested different parameter configurations for
devEMF::emf()
(e.g. settingemfPLUS = FALSE
), to no effect.Unfortunately, I do not have access to emf files NOT created by
devEMF::emf()
, so I could not test whether the problem exists for all emf files in general, or only for the ones created bydevEMF
.Using other devices / image formats (such as png) with the code below worked with no problems.
I have also looked at other packages, such as
openxlsx::insertImage()
, but that function does not support emf files in the first place.It would be fantastic to get this working somehow. I have used
devEMF::emf()
extensively for R Markdown and Word documents, with great results, so I am very interested in getting this to work for Excel as well.Created on 2022-05-02 by the reprex package (v2.0.1)
Session info
The text was updated successfully, but these errors were encountered: