Home > php教程 > PHP源码 > 简单生成EXCEL

简单生成EXCEL

PHP中文网
Release: 2016-05-25 17:09:53
Original
1282 people have browsed it

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

                       


Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template