I'm trying to export data into an excel file with the specific sheet name. Which package and example code are more convenient to use.
write_xlsx()
I want to do below
write_xlsx( data = "result", sheet = "first", excel = "Constraint.xlsx")
Once run the script, the following error is out.
Error in write_xlsx(data = "result", sheet = "first", excel = "Constraint.xlsx") :
unused arguments (data = "result", sheet = "first", excel = "Constraint.xlsx")
How to overcome, please suggest to me!
write_xlsx (from the writexl - package) can be used to save multiple sheets. The help isn't very nice:
"x = data frame or named list of data frames that will be sheets in the xlsx".
Actually what you do is:
write_xlsx(list(Nameofsheet1 = dataforsheet1,
Nameofsheet2 = dataforsheet2,
Nameofsheet3 = dataforsheet3),
"filename.xlsx")
Matthias:
write_xlsx(list(Nameofsheet1 = dataforsheet1,
Nameofsheet2 = dataforsheet2,
Nameofsheet3 = dataforsheet3),
"filename.xlsx")
Thanks @Matthias
It works well, the way I want.
write_xlsx(list(constraint = result),"hfc_outputs.xlsx")