1

I'm trying to export multiple data frames into one excel file with multiple sheets.

This is the code I used:

setwd('C:/Users/Desktop/R')
library("readxl")
library("writexl")
AR <- read_excel("FEB_AR.xlsx",sheet="After sort")
library(plyr)
#Top 10
Top_10 = AR[order(AR$Amount, decreasing= T),]
Top_10 = Top_10[1:15,]
Top10 <- as.data.frame(Top_10)
#Top Over 60
Top_Over_60 = AR[order(AR$Total, decreasing= T),]
Top_Over_60 = Top_Over_60[1:15,]
TopOver60 <- as.data.frame(Top_Over_60)
sheets <- list("Top10" = sheet1, "TopOver60" = sheet2) 
write_xlsx(sheets, "C:/Users/Desktop/R") 

This is the message I receive:

> sheets <- list("Top10" = sheet1, "TopOver60" = sheet2) 
Error: object 'sheet1' not found
> write_xlsx(sheets, "C:/Users/Adi.Koren/Desktop/R")
Error in is.data.frame(x) : object 'sheets' not found

Also, I can't use the packages 'openxlsx' or 'xlsx' because they require a java update which I can't download (it's a work computer).

1 Answer 1

2

Try the following :

sheets <- list(sheet1 = Top10, sheet2 = Top_Over_60) 
writexl::write_xlsx(sheets, "result.xlsx") 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.