Generate downloadable CSV/JSON from array in virtual page

On a virtual page I generate a table from SQL-Data. I want to create a button, to download this data as CSV or JSON file.
How can I create the file on demand or POST the data to a separate route?

Resolved it by approaching the issue from a different angle.
Re-queried the database using the same parameters at the separate route. While it may not be the most optimal solution, if it proves effective, it’s far from being a foolish approach. :smile: