Here’s a snippet showing the code for the conversion:
In order to export to Excel, the preview needs to contain the required data (see this blog post for details).