问题
I have trouble when exporting data from R into an Excel file containing a graphic with additional text.
The problem is relatively specific.
So I have a datatable
in R, like this one :
library(lubridate)
library(dplyr)
library(data.table)
library(openxlsx)
Sys.setenv(LANGUAGE='en')
MWE <- data.table(
Date=rep(seq(ymd("2020-1-1"), ymd("2020-3-30"), by = "days")),
Country1=rnorm(90,2,3),
Country2=rnorm(90,2,3))
I then export it in an Excel file using an openxlsx
option
Fichier <- loadWorkbook("File.xlsx")
writeData(Fichier, sheet="D.Brutes", MWE , colNames=T)
saveWorkbook(Fichier,"File.xlsx",overwrite=T)
Now this datatable, now in an Excel sheet, is used to create a graph (two curves with the values for Country 1 and Country 2 over time), in a separate sheet.
Everything works, until I add some text on the graphics (e.g. "source : Eurostat"), which then tells me that (approximate translation) : We have encountered a problem with the file "file.xlsx" but we can try to retrieve the maximum amount of information. If this file is reliable, click on yes
.
Then I get the following message and the graphic is deleted
This problem happens whether the graphic is on the separate sheet or on the same one.
Is it something only I experience ? What could be the cause and how could I get around that ?
来源:https://stackoverflow.com/questions/64756679/exporting-data-from-r-into-an-excel-file-that-contains-a-graphic-with-additional