php输出excel格式的问题
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><?php @$con = mysql_connect("localhost","root","mysql"); mysql_query('set names gb2312'); if (!$con){ die("数据库链接失败:".mysql_error()); exit; } $data = mysql_select_db("berecord",$con); //include('conn.php'); //mysql_query('set names gb2312'); if(!$data){ echo mysql_error(); mysql_close($con); //关闭数据库链接 exit; } else if($name=="" && $carnumber=="" && $do=="" && $usercode==""){ //当四项数据全为空时 $sql = "select * from record; $result = mysql_query($sql,$con); $fp = fopen("php://output","a"); $head = array("年","月","日","周","姓名","年龄","班级","学号","上/下学时间","学习记录","体育成绩","学习汇报","学习总结")"; foreach($head as $i => $v){ $head[$i] = iconv('utf-8','gb2312',$v); //格式转换 //$head[$i] = mb_convert_encoding("$v","utf-8","gb2312"); } fputcsv($fp,$head); while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ //fputcsv($fp,array_map('zero_change',$row)); fputcsv($fp,$row); //echo "<br>"; 没有必要 在$row输出时就实现了 } mysql_close($con); } ?>
100 | This is an example |
50 | Do you understand? |