how export a list on excel on a same sheet

How do I export a list of tibbles to an excel but send it all to the same sheet? because exporting it with write_xlsx exports it to different sheets. I have a list of 17 tibbles, all with different classes and column names and different numbers of rows. I use write_xlsx but it exports me an excel with 17 sheets, and I only want 1 that contains all the tibbles. all the names of the subelements of the list are different.

Here is one approach using the openxlsx package.

DF1 <- data.frame(Name=c("A","B","C"),Value=1:3)
DF2 <- data.frame(Number=1:4,T_F=c("TRUE","FALSE","FALSE","TRUE"),
DF3 <- data.frame(ID=1:10)
DF4 <- data.frame(Date=c("2020-02-13","2022-09-08"),Type=c("X","E"),
DFlist <- list(DF1,DF2,DF3,DF4)
Rows <- map_dbl(DFlist,nrow)+2 #add 1 for the header and 1 for a spacer row
CumRows <- cumsum(Rows)
WriteRows <- c(1,CumRows[1:length(CumRows)-1]+1)
wb <- createWorkbook()
WriteFunc <- function(DF,ROW) writeData(wb,"MainSheet",DF,startRow = ROW)
walk2(DFlist, WriteRows, .f = WriteFunc)
saveWorkbook(wb, file = "Test.xlsx")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.