首页 > Web开发 > 详细

PHP导出excel,无乱码

时间:2016-08-23 18:37:38      阅读:242      评论:0      收藏:0      [点我收藏+]

php部分

header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=Export_test.xlsx");
$OutputExcel = S(‘OutputExcel‘);
$this->assign(‘OutputExcel‘,$OutputExcel)->display(‘test‘);

html部分

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<style id="Classeur1_16681_Styles"></style>
</head>
<body>
<div id="Classeur1_16681" align=center x:publishsource="Excel">
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
<tr>
<th>序号</th>
<th>姓名</th>
<th>编号</th>
<th>个人识别码</th>
<th>身份证</th>
</tr>
<?php foreach ($OutputExcel as $key => $value): ?>
<tr>
<td>{$key+1}</td>
<td>{$value[‘stuff_nicname‘]}</td>
<td>{$value[‘stuff_number‘]}</td>
<td>{$value[‘stuff_code‘]}</td>
<td>{$value[‘stuff_idcard‘]}</td>
</tr>
<?php endforeach ?>
</table>

PHP导出excel,无乱码

原文:http://www.cnblogs.com/wenxinphp/p/5800312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!