我正在使用cakephp的xlsHelper以excel格式导出。除了“mac”操作系统外,所有操作系统中的所有主要浏览器和打开文件都能正常工作吗?
答案 0 :(得分:1)
这可以帮助你..
<?php
$this->layout="";
$filename=strtotime("now");
header ("Expires: 0");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/vnd.ms-excel");
header ("Content-Disposition: attachment; filename=".$filename.".xls");
header ("Content-Description: Generated Report" );
// echo 'Number of Rows::'."\t" . count($test)."\n";
// echo "\n";
echo 'Id' . "\t" .
'EnrollmentId' . "\t" .
'IDS' . "\t" .
'sysreq' . "\t" .
'sysproc' . "\t" .
'Request' . "\t" .
'Response' . "\t" .
'Created' . "\n";
foreach($test as $val):
echo $val['abc']['id']. "\t" .
$val['xyz']['enrollment_id']. "\t" .
$val['bca']['IDS']. "\t" .
$val['mca']['_sysreq']. "\t" .
$val['car']['_sysproc']. "\t" .
$val['azx']['SYSBATCHNO']. "\t" .
$val['tyu']['MSGS']. "\t" .
$val['wer']['created']. "\n";
endforeach;
&GT;