我正在使用jQuery表格到CSV插件。我更改了彈出窗口,以便它告訴瀏覽器下載CSV文件。jQuery表格到CSV導出
它是:
function popup(data) {
var generator = window.open('', 'csv', 'height=400,width=600');
generator.document.write('<html><head><title>CSV</title>');
generator.document.write('</head><body >');
generator.document.write('<textArea cols=70 rows=15 wrap="off" >');
generator.document.write(data);
generator.document.write('</textArea>');
generator.document.write('</body></html>');
generator.document.close();
return true;
}
我把它改爲:
function popup(data) {
window.location='data:text/csv;charset=utf8,' + encodeURIComponent(data);
return true;
}
它的工作原理,在大多數情況下。它仍然需要你找到你的電子表格軟件,並創建你自己的文件名......因爲它會創建一個奇怪的文件名(例如:14YuskG_.csv.part)。
有關如何改善此問題的任何建議?
的jQuery表到CSV插件:http://www.kunalbabre.com/projects/table2CSV.php,感謝注:Kunal Babre – timborden 2009-05-28 14:10:43