Export selected data from dataset to file (i.e. Excel) from frontend

I know there’s got to be a way to do this but I haven’t been able to find any examples online (mainly via Wix Code) that detail what I’m meaning.

I’d like to be able to take a filtered dataset and/or select a number of field codes from a dataset and export the corresponding data to a downloadable file such as Excel.
In example, this could be used to export contact information from an online entry.

Correct me if I’m wrong but I think this would be possible by fetching the data from the dataset and formatting as a string. Then convert the data to CSV for export and download?
I just don’t know how to do this yet with Wix Code so some example code would be great.

See the forum post How to download the contents of a data collection in a csv file for how to do this.