admin_user.php
<?php
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
$objPHPExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);$objWriter->save("resume.xls");$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
?>
在模版页面admin_user.html中
<!--IF($dc)-->
<!--$objPHPExcel = new PHPExcel();iconv('utf-8", "gb2312", $filename);
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save("resume.xls");
ob_clean();
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
Header('content-Type:application/vnd.ms-excel;charset=utf-8');
header("Pragma: public");
header("Expires: 0″);
header("Cache-Control:must-revalidate, post-check=0, pre-check=0″);
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header('Content-Disposition:attachment;filename="resume.xlsx"');
header("Content-Transfer-Encoding:binary");-->
<table cellpadding="0" cellspacing="1" class="list" id="tree_list" >
<tr>
<th width="7%">用户编号</th>
<th width="12%">用户名</th>
<th width="18%">EMAIL</th>
<th width="10%">注册时间</th>
<th width="10%">用户类型</th>
<th width="12%">最后登陆</th>
<th width="12%">登陆IP</th> </tr>
<!--$userlist AS $v-->
<tr align="center"> <td align="left" class="td1" style="text-align:center;"><span><a href="#">{v[uid]}</a></span></td>
<td class="ud" >{v[username]}</td>
<td class="od" >{v[email]}</td>
<td class="gd" >{run:}echo date('Y-m-d',$v[date_reg]){/run}</td>
<td class="td"><!--IF($v[usertype]==0)--><font color="green">普通用户</font><!--ELSEIF($v[usertype]==2)--><font color="green">套红人才</font><!--END--></td>
<td>{run:}echo date('Y-m-d',$v[date_login]){/run}</td>
<td>{v[iponline]}</td>
</tr>
<!--END-->
</table><!--$objWriter->save('php://output');-->
<!--END-->
出现乱码,从来没做过导出excel,是不是程序不对?求解
<?php
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
$objPHPExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);$objWriter->save("resume.xls");$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
?>
在模版页面admin_user.html中
<!--IF($dc)-->
<!--$objPHPExcel = new PHPExcel();iconv('utf-8", "gb2312", $filename);
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save("resume.xls");
ob_clean();
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
Header('content-Type:application/vnd.ms-excel;charset=utf-8');
header("Pragma: public");
header("Expires: 0″);
header("Cache-Control:must-revalidate, post-check=0, pre-check=0″);
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header('Content-Disposition:attachment;filename="resume.xlsx"');
header("Content-Transfer-Encoding:binary");-->
<table cellpadding="0" cellspacing="1" class="list" id="tree_list" >
<tr>
<th width="7%">用户编号</th>
<th width="12%">用户名</th>
<th width="18%">EMAIL</th>
<th width="10%">注册时间</th>
<th width="10%">用户类型</th>
<th width="12%">最后登陆</th>
<th width="12%">登陆IP</th> </tr>
<!--$userlist AS $v-->
<tr align="center"> <td align="left" class="td1" style="text-align:center;"><span><a href="#">{v[uid]}</a></span></td>
<td class="ud" >{v[username]}</td>
<td class="od" >{v[email]}</td>
<td class="gd" >{run:}echo date('Y-m-d',$v[date_reg]){/run}</td>
<td class="td"><!--IF($v[usertype]==0)--><font color="green">普通用户</font><!--ELSEIF($v[usertype]==2)--><font color="green">套红人才</font><!--END--></td>
<td>{run:}echo date('Y-m-d',$v[date_login]){/run}</td>
<td>{v[iponline]}</td>
</tr>
<!--END-->
</table><!--$objWriter->save('php://output');-->
<!--END-->
出现乱码,从来没做过导出excel,是不是程序不对?求解
解决方案 »
- 被hotmail垃圾邮件的问题求助,比较急
- curl 模拟登录豆瓣
- 移植php到arm linux的问题,请教各位大虾
- 代码意思问题
- ecshop安装模板不可写怎么解决?
- 哪里有<<php and mysql web development>> 4th edition的随时源代码下载啊?
- 第一次做PHP系统,请老师们帮一下忙,做一个日志管理!
- kindeditor 在IIS中上传图片失败!但是在Apache中就成功!
- Bootstrap File Input 案例
- 微信jssdk 上传图片接口官方的是上传到微信服务器怎么上传到自己的服务器
- 怎么样才能完全看懂源码和别人写的代码
- PHP采集的一个函数,高手帮我优化一下
在你填充的字段进行转码;
$objActSheet -> setCellValue($key.'1', transformUtf8($_totaltitle[$value]));//列值
//$objActSheet -> getColumnDimension($key) -> setWidth();//宽度
$objActSheet -> getStyle($key.'1') -> getAlignment() -> setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet -> setCellValue($key.($i+1), transformUtf8($ary[$i-1] -> $value));
$objActSheet -> getStyle($key.($i+1)) -> getAlignment() -> setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);transformUtf8是一个自己手写的转码函数;function transformUtf8($str){
if(!is_utf8($str)){
return iconv("gbk","utf-8",$str);
}
return $str;
}