Javascript或Flash导出到CSV / Excel

问题描述:

有没有将JSON数据导出到CSV / Excel而不与服务器端进行任何交互?仅使用JavaScript?还是Flash?我正在使用ZeroClipboard将该值复制到剪贴板中,但是我想从浏览器(FF,Chrome,IE等)直接打开生成的值到Excel中。

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 the value into the clipboard but I'd like to open directly the generated value into Excel from the browser (FF, Chrome, IE, etc...).

Thx。

远离,从表到Excel最干净,最简单的导出是 Jquery DataTables表工具插件。您可以获得一个网格,对数据进行排序,筛选,订购和打印,只需添加几行代码和两个小文件,就可以导出到 Excel PDF strong>, CSV 剪贴板打印机

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.

所有需要的代码:

$(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.