Home > php教程 > php手册 > php 导入导出excel:php导出excel

php 导入导出excel:php导出excel

WBOY
Release: 2016-06-21 08:50:09
Original
1732 people have browsed it

/**
* @param string $filname //输出的文件名
* @param string $type //编码类型
* @param string $array //excel的标题
* @param string $data //需要的数据data
**/
function exportExcel($filname, $type = 'utf-8', $array, $data) {
if (empty ($data)) {
echo "<script>alert('sorry,no data!');history.go(-1);</script>";
exit;
}
$filname = iconv("utf-8", "gb2312", $filname);
header("Content-type:application/vnd.ms-excel;");
header("Content-Disposition:attachment;filename=$filname.xls");
echo "";
echo '';
foreach ($array as $val) {
echo "";
}
echo '';
foreach ($data as $val) {
if(is_array($val)){
echo '';
foreach ($val as $v) {
echo '';
}
echo '';
}else {
echo '';
echo '';
echo '';
}
}
echo '
$val
' . $v . '
' . $val . '
';
exit;
}
  本文链接http://www.cxybl.com/html/wlbc/Php/20130326/37395.html



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