我正在使用DataTables和TableTools来格式化表格 当我希望它将表格导出为.xls结果时 仍然是.csv。 .pdf导出工作完美但如何制作“TableTools” 将表导出为.xls?
提前致谢
答案 0 :(得分: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;
答案 1 :(得分: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" ] }
});