HarlanH / code-for-dc-edu

Code for DC Education Project
20 stars 17 forks source link

export view to CSV #9

Open HarlanH opened 11 years ago

HarlanH commented 11 years ago

So that people can download the data underlying what they're looking at

HarlanH commented 11 years ago

there are relatively straightfoward ways to do this in Chrome, and maybe FF, but it seems like IE is a nonstarter without a server call. We'll want to decided whether to support it only for certain browsers, or wait until we have/need a server.

http://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side http://stackoverflow.com/questions/4639372/export-to-csv-in-jquery

cherihung commented 11 years ago

yeah, as far as I can tell, the best "solution" for IE, without a server call, is to print out the data in csv format on a blank page. then user can copy and save the data as csv manually :(

with this bit of extra code (from here http://feras.us/blog/2011/10/25/javascript-to-csv-excel-google-docs-ready-using/)

if (navigator.appName != 'Microsoft Internet Explorer') {
        window.open('data:text/csv;charset=utf-8,' + escape(str));
    }

but it's probably worth implementing this for the other non-IE browsers. It would be a very nice feature.

alternatively, IE users can get a "Print" option instead from a table we dynamically generate.