How do I get the results of a WP_Query so a user can download a CSV?

I have a custom post type with several custom fields. I would like users to be able to download the results of the WP_Query to CSV. How can I accomplish this?

Thanks!