简单生成EXCEL
程序员文章站
2022-05-06 13:25:48
...
简单的生成EXCEL文件
$arr_list = array(); //数据库读取, 获取要输出到EXCEL的数组 header('Content-type: application/vnd.ms-excel;'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Disposition: attachment; filename=activity.xls'); //filename:文件名 ob_start(); //打开缓存区 include 'file.html'; //输出内容到缓存区 $output = mb_convert_encoding(ob_get_clean(), 'GBK', 'UTF-8'); //缓存区取出,转换编码 echo $output; //输出 <?php echo implode("t", array_keys($arr_list[0])),"n"; foreach($arr_list as $value){ echo implode("t", $value),"n"; } ?>