Download results as csv in Web Appbuilder

12-16-2019 11:52 AM
New Contributor II

Hi, I'm building an app using the ArGIS Web Appbuilder. I'm using the Info Summary Widget to display features which can be filtered using the Filter Widget. I would like to add the option of downloading the filtered results as a csv. Optimally, this should just be a download button without having to go through the weeds like with the attribute table widget or screening widget. Any help is much appreciated. 

0 Kudos
2 Replies
New Contributor III


You will most likely need to take the code from one of these two links and adapt it to your needs:

Create and download data in CSV format using plain JavaScript 

How to export JavaScript array info to csv (on client side)? - Stack Overflow 

I've done some research on this issue recently and all of the solutions I came across were similar to the above. Basically all of the solutions come down to making a hidden link (an html 'a' element) that is empty but has a download attribute with your file name in it. Then the link clicks itself, which is what the below code does.

Essentially, you would have this code fire when your button is clicked. Caveat to my answer: I never got anything to work in internet explorer/edge.

var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "my_data.csv");
document.body.appendChild(link); // Required for FF; // This will download the data file named "my_data.csv"

New Contributor II

Hi Eric,

Thanks for your recommendations. I'll give it a try.

0 Kudos