Which package to be used for exporting data into excel with the specific sheet name ?

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")

Thanks @Matthias
It works well, the way I want.

write_xlsx(list(constraint = result),"hfc_outputs.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.