1. Turn array of objects to a HTML table
2. Turn table data into Excel
Build CSV Data & Download Link
Our makeCSV() function will do 2 things. 1, create CSV data out of JSON data. 2, Create a link to download our CSV data into an excel file.
Our excel data wont actually reference the HTML table, just the data in it. As you will see in the demo code below, when we are looping through the array to create the table we are also creating a CSV file that represents the table exactly.
The CSV data will be stored in its own variable and will be triggered by the download button to which we attached a link to. Review the code below for a better understanding of whats going on here and test out the download button.