Is there anyway to export JSON data to CSV/Excel without any interaction with the server side? Using Javascript only? or Flash? I\'m currently using ZeroClipboard to copy th
Far and away, the cleanest, easiest export from tables to Excel is Jquery DataTables Table Tools plugin. You get a grid that sorts, filters, orders, and pages your data, and with just a few extra lines of code and two small files included, you get export to Excel, PDF, CSV, to clipboard and to the printer.
This is all the code that's required:
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/swf/copy_cvs_xls_pdf.swf"
}
} );
} );
So, quick to deploy, no browser limitations, no server-side language required, and most of all very EASY to understand. It's a win-win. The one thing it does have limits on, though, is strict formatting of columns.
There doesn't seem to be a foolproof way to do it client-side only on all browsers and file sizes. All solutions seem to use one of the following:
Depending on your use case you might be able to get away with one of the above though. Here are some other posts on SO with more details.
Note that this part of the answer from Ramandeep Singh is incorrect:
So, quick to deploy, no browser limitations, no server-side language required, and most of all very EASY to understand.
DataTables does use a flash plugin if you look at the code. It will not work on mobile browsers (iOS, recent Android devices without rooting, Windows 8 RT without hacks or MSFT approval process). Here is a post from their site as well: http://www.datatables.net/forums/discussion/7563/export-to-csvpdf-without-tabletools/p1