1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
library(openxlsx)
library(datasets)
ddf=airquality
colnames(ddf)=c("Ozone (µg/m³)","Insolation","Vitesse vent","Température","Mois","Jour")
img <- system.file("einstein.jpg", package = "openxlsx")
for (i in 1:3)
{
wb <- createWorkbook()
addWorksheet(wb, sheetName=paste0("tab",i), gridLines = TRUE)
openxlsx::writeData(wb,
sheet=paste0("tab",i),
x=ddf,
startCol = i,
startRow = i,
xy = NULL,
colNames = TRUE,
rowNames = FALSE)
insertImage(wb, sheet=paste0("tab",i),
img, startRow = 10,
startCol = 10, width = 6, height = 6)
saveWorkbook(wb, paste0("Fichier_",i,".xlsx"), overwrite = TRUE)
} |
Partager