Data Frame Error

The error message suggests you have no data frame called x in your working environment, so there is nothing to be saved as xlsx, to give you better help. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ: