I am using ‘openxlsx’ package in R. ٰI want to add some data in xlsx file. I have used following code to create the workbook and add worksheet in it.
wb=createWorkbook()
addWorksheet(wb,"sheet 1")
writeData(wb,sheet = 1,"From",startCol = 1,startRow = 1)
writeData(wb,sheet = 1,"To",startCol = 2,startRow = 1)
writeData(wb,sheet = 1,"From",startCol = 1,startRow = 2)
writeData(wb,sheet = 1,"From",startCol = 1,startRow = 2)
saveWorkbook(wb,"file.xlsx",overwrite = TRUE)
This code was working well for a long time, But recently, I am facing this error
Error in addWorksheet(wb, "sheet 1") : First argument must be a Workbook.
How this error will be resolved?
I had the same issue with this. I did the followings and it fixed the issue. Maybe it can solve yours.
I had the same problem and I just unloaded the package, reinstalled it and reloaded it, and it worked (without having to close R studio) :
detach("package:openxlsx", unload=TRUE)
install.packages("openxlsx")
library(openxlsx)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With