php导出excel乱码问题
最近在做一个php导入导出excel;
试了PHPEXCEL 和Spreadsheet_Excel_Writer都是不好用的,保存本地是好用的,可是输出浏览器就是乱码,而且可以看到乱码的文件应该是当前网页的HTML。谁能解决一下
// 创建一个处理对象实例
$objExcel = new PHPExcel();
//*************************************
//设置文档基本属性
$objProps = $objExcel->getProperties();
$objProps->setCreator("Zeal Li");
$objProps->setLastModifiedBy("Zeal Li");
$objProps->setTitle("Office XLS Test Document");
$objProps->setSubject("Office XLS Test Document, Demo");
$objProps->setDescription("Test document, generated by PHPExcel.");
$objProps->setKeywords("office excel PHPExcel");
$objProps->setCategory("Test");
//*************************************
//设置当前的sheet索引,用于后续的内容操作。
//一般只有在使用多个sheet的时候才需要显示调用。
//缺省情况下,PHPExcel会自动创建第一个sheet被设置SheetIndex=0
$objExcel->setActiveSheetIndex(0);
$objActSheet = $objExcel->getActiveSheet();
//设置当前活动sheet的名称
$objActSheet->setTitle('testSheet');
//到浏览器
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-type:charset=utf-8");
header('Content-Type: application/vnd.ms-excel');
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objExcel, 'Excel5');
$objWriter->save('01simple.xls');
$objWriter->save('php://output');
保存在服务器上的文件是好的,可是弹出保存在客户端的文件有问题。
乱码如:
邢唷?;?
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????B?=?r8X"1?Calibri? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??8???????????纮?櫃?f???f??烫???????????櫶?櫶虣?虣3f?烫櫶??ff枛3f3檉333??f33333testSheet??g??
$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$} $}!!$}""$}##$}$$$}%%$}&&$}''$}(($}))$}**$}++$},,$}--$}..$}//$}00$}11$}22$}33$}44$}55$}66$}77$}88$}99$}::$};;$}<<$}==$}>>$}??$}@@$}AA$}BB$}CC$}DD$}EE$}FF$}GG$}HH$}II$}JJ$}KK$}LL$}MM$}NN$}OO$}PP$}QQ$}RR$}SS$}TT$}UU$}VV$}WW$}XX$}YY$}ZZ$}[[$}\\$}]]$}^^$}__$}``$}aa$}bb$}cc$}dd$}ee$}ff$}gg$}hh$}ii$}jj$}kk$}ll$}mm$}nn$}oo$}pp$}qq$}rr$}ss$}tt$}uu$}vv$}ww$}xx$}yy$}zz$}{{$}||$}}}$}~~$}$}?$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}$}?$*+??&ffffff?'ffffff?(?)?"dXX333333?333333?>?@
Root Entry????F2沖坹?2沖坹?Workbook??????F??????????????????????????????
<b>Warning</b>: Cannot modify header information - headers already sent in <b>C:\Apache2.2\htdocs\OpenPNE\webapp\lib\OpenPNE\Smarty.php</b> on line <b>117</b><br />
<ul class="adminManage">
<a class="tab" href="?m=admin&a=page_list_c_image">涓婁紶*鍐呭绠$悊</a>
<ul id="adminImageKakikomiCont" class="pull">
<li><a href="?m=admin&a=page_list_c_image">涓婁紶鍥惧儚鍚嶅崟</a></li>
<li><a href="?m=admin&a=page_list_c_file">涓婁紶鏂囦欢鍚嶅崟</a></li>
<li><a href="?m=admin&a=page_diary_comment_list">鏃ヨ鐣欒█绠$悊</a></li>
<li><a href="?m=admin&a=page_commu_list">鐝骇绠$悊</a></li>
<li><a href="?m=admin&a=page_topic_list">甯栧瓙?娲诲姩绠$悊</a></li>
<li><a href="?m=admin&a=page_topic_comment_list">甯栧瓙?娲诲姩鐨勭暀瑷?鐞?lt;/a></li>
[解决办法]
header 函数前有输出
Smarty.php 的117行是什么