I've been struggling with this for a while so I thought I'd put it out there to see if anyone had any suggestions—I'm not too experienced with the guts of views.
What I'm trying to do is export a view as CSV; yes, I know there is CSV export in the views_bonus project but these views can have thousands of rows and the csv export times out. Messing around with the download_data module I found that if I have the SQL query string I can dump the data out pretty fast and timeouts aren't a problem. However so far I've had to hardcode the SQL query for each view I want to export. But I want to be able to dump any view with any filters etc applied.
I spent a while trying to get a hold of the query string in views_post_render() and stashing it in the session to be picked up by my module when the user clicks a link at the bottom of the page, but this isn't giving me what I need—it doesn't seem to differentiate which fields are displayed and which aren't, and it doesn't follow node reference fields through to get their titles.
I know I could keep messing around with it and probably bend it to my will with some SQL hacking, but I feel intuitively this is the wrong approach. I'd love to know if there's some better approach I'm missing.