$.fn.tableToCSV = function(filename) {
var csv_str = "";
function createCSVRow(data) {
var row = "";
for (var i = 0; i < data.length; i++) {
var cell = (""+data[i]).replace('"', '""');
row += ~cell.indexOf(";") ? '"' + cell + '";' : cell + ";";
}
return row.replace(/(;$)/, "");
}
function popup(data){
$("body").append('
');
$("#exportdata").val(data);
$("#exportform").submit().remove();
return true;
}
this.each(function() {
$("tr", this).each(function() {
var cells = $("td,th", this).map(function() {
return $(this).text();
}).get();
csv_str += createCSVRow(cells) + "\n";
});
});
popup(csv_str);
//window.location = "data:application/csv;charset=utf=8;base64," + window.btoa(unescape(encodeURIComponent(csv_str)));
};
export.php