在网页上添加了个按钮就出现乱码了,去掉按钮是正常的!
<?php
include("conn.php");
 $zhanghao=$_POST[zh];
?>
<form action="ceshi.php" method="post">
<input type="submit" name="submit" value="提交">
</form>
<?php
include './Classes/PHPExcel.php';//("Classes/PHPExcel.php"); 
include './Classes/PHPExcel/Writer/Excel5.php'; 
include './Classes/PHPExcel/IOFactory.php'; 
 if ($_POST[submit]){
$m_objPHPExcel = new PHPExcel();
$str1  = iconv('gb2312', 'utf-8', '日期');
$str2  = iconv('gb2312', 'utf-8', '日期');
$str3  = iconv('gb2312', 'utf-8', '日期');
$str4  = iconv('gb2312', 'utf-8', '日期');
$str5  = iconv('gb2312', 'utf-8', '日期');
$m_objPHPExcel->getActiveSheet()->setCellValue('A1', $str1);
$m_objPHPExcel->getActiveSheet()->setCellValue('B1', $str2);
$m_objPHPExcel->getActiveSheet()->setCellValue('C1', $str3);
$m_objPHPExcel->getActiveSheet()->setCellValue('D1', $str4);
$m_objPHPExcel->getActiveSheet()->setCellValue('E1', $str5);
$m_exportType = "excel";
$m_strOutputExcelFileName = date('Y-m-j_H_i_s').".xls"; //输出文件名
$objWriter = PHPExcel_IOFactory::createWriter($m_objPHPExcel, 'Excel5');
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-excel;");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
header("Content-Disposition:attachment;filename=".$m_strOutputExcelFileName);
header("Content-Transfer-Encoding:binary");
$objWriter->save("php://output");  
 }
?>