I often look at the code of others with respect and admiration. Peter Kriegel (Germany) wrote Export-XLSX.ps1, an amazing script which lets you export data into a real XLSX file without Excel being installed. The script also enables you to directly append worksheets to XLXS files. His website, http://www.admin-source.de, hasn’t been updated in a while, and the automatic translate function is broken. It isn’t clear to me how to reach Peter, as I typically don’t post the code of others with so few changes, so I want to be clear — this isn’t my work.
I converted the original script to an advanced function, and made sure the Help was functioning right. The only limitation is with formatting, which means it will look pretty much like a file from Export-CSV. Nonetheless, if you have scripts running on servers where you really don’t want to install Excel, this is an excellent function to use. The script is heavily commented and has examples in the help.