Home  >  Article  >  php教程  >  简单生成EXCEL

简单生成EXCEL

PHP中文网
PHP中文网Original
2016-05-25 17:09:531264browse

简单的生成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";
}
?>

                       


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn