function printResultExcel_one_sheet($statResult, $fileName " />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>PHP</em>做一个下载EXCEL的表格 知道代码的求发-php excel表格,ex

<em>PHP</em>做一个下载EXCEL的表格 知道代码的求发-php excel表格,ex

作者:乔山办公网日期:

返回目录:excel表格制作


右键—属性—最后修改时间。

function printResultExcel_one_sheet($statResult, $fileName = "total") {
header ( "Content-type:application/vnd.ms-excel;charset=utf-8" );
header ( "Content-Disposition:filename=".$fileName.".xls" );
echo '<table border="1" cellspace="1" bordercolor="#D3D3D3">';
foreach ( $statResult as $result ) {
echo "<tr>";
foreach ( $result as $i ) {
echo '<td style="vnd.ms-excel.numberformat:@">'.$i.'</td>';
}
echo "</tr>";
}
echo '</table>';
}

$statResult 是你的数组,然后调用这个方法就可以下载excel文件了




$retdata=array(); //内容 //二维数组

$filename= "文件.csv";
//生成头文件

$now = gmdate("D, d M Y H:i:s");
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
header("Last-Modified: {$now} GMT");

header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename={$filename}");
header("Content-Transfer-Encoding: binary");
//生成表格
$title=array('"金额"','"会员"','"余额e799bee5baa6e79fa5e98193e59b9ee7ad94361"'); //每列的标题
$str=implode(',',$title) . PHP_EOL;
foreach ($retdata as $row) {
// print_r($row);
$str_arr = array();
foreach ($row as $column) {
$str_arr[] = '"' . str_replace('"', '""', $column) . '"';
}
$str.=implode(',', $str_arr) . PHP_EOL;
}
print(chr(0xEF).chr(0xBB).chr(0xBF));
echo $str;

相关阅读

关键词不能为空
极力推荐
  • <em>excel</em>公式<em>if</em>函数三个以上条件怎

  • =IF(A1*LOOKUP(A1,{0,1,2},{3,6,9})+3>30,30,A1*LOOKUP(A1,{0,1,2},{3,6,9})+3)公式中{0,1,2}里面的来0意思是如果源A1大于等于0小于1时,百A2=A1*3+3,如果更小,把0改为适合度的值即可。excel2007中if函数嵌

ppt怎么做_excel表格制作_office365_word文档_365办公网