2012-07-19 66 views
0

我正在使用DataTables和TableTools來格式化表 ,當我希望它將表導出爲.xls時,結果 仍然是.csv。 .pdf導出工作完美無瑕,但如何使「TableTools」 將表導出爲.xls?Jquery - 表格工具如何導出爲xls?

enter image description here

在此先感謝

回答

2

您可以使用庫,如: http://code.google.com/p/php-excel/http://phpexcel.codeplex.com/

或者你也可以使用頭,使simpel XLS文件

$filename ="excelreport.xls"; 
$contents = "testdata1 \t testdata2 \t testdata3 \t \n"; 
header('Content-type: application/ms-excel'); 
header('Content-Disposition: attachment; filename='.$filename); 
echo $contents; 
+0

對不起,我剛剛發現我的misatke – NiCU 2012-07-19 14:09:33

2

試試這個,問題解決.. :)

$('#dt_gal').dataTable({ "sDom": 'T<"clear">lfrtip', 
"oTableTools": {"sSwfPath": "<?php echo base_url() ?>asset/export/swf/copy_csv_xls_pdf.swf" , 
"aButtons": [ 
    "copy", 
    { "sExtends": "csv", 
    "sTitle": "titleExport csv", 
    "sFileName": "*.csv" 
    }, 
    { "sExtends": "xls", 
    "sTitle": "titleExportxls", 
    "sFileName": "*.xls" }, 
    { "sExtends": "pdf", 
    "sTitle": "titleExportpdf", 
    "sFileName": "*.pdf" 
    }, 
    "print" ] } 
});