I'm not 100% sure how to do it and if it's possible, however a short search for "download csv js" suggests that it might be possible but you'd need to be able to use the Blob API I think, which may be possible with a custom action. You'd first need to parse your data into the correct CSV format, so you'd need to work on a formula that would do that.
I'll leave this for others to contribute to as well. 🙂