php关于phpexcel乱码问题
何建城 2015-12-26 11:44:40 导出excel文件 出现了一个问题 在导出行数5行以上的时候 导出数据格式正常 在5行一下数据的时候 中文全部乱码 这个问题请教各位大神 代码贴出来下面
$filename='exceptionOrder'.date('Y-m-d');
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Content-type:application/vnd.ms-excel;charset=UTF-8");
header("Content-Disposition:attachment;filename=".$filename.".xls");
header("Pragma: no-cache");
header("Expires: 0");
$table = '';
$table.='<html xmlns:x="urn:schemas-microsoft-com:office:excel" ><table cellpadding="0" cellspacing="0" border="1" style="br:mso-data-placement:same-cell;">'.PHP_EOL;
$table.='<thead>
<tr>
<td style="font-size:14px;font-weight:bold;padding:5px;">序号'.iconv("gb2312","UTF-8",'序号').'</td>
<td style="font-size:14px;font-weight:bold;padding:5px;">SKU</td>
<td style="font-size:14px;font-weight:bold;padding:5px;">仓库</td>
<td style="font-size:14px;font-weight:bold;padding:5px;">库位</td>
<td style="font-size:14px;font-weight:bold;padding:5px;">实库存</td>
</tr>
</thead>'.PHP_EOL;
$i = 1;
foreach($data as $key =>$val){
if($val['orders_warehouse_id']==1000){
$str = "深圳一仓";
}else if($val['orders_warehouse_id']==1025){
$str = "义乌仓";
}
$table.='<tr><td>'.$i.'</td>
<td>'.$val['product_sku'].'</td>
<td>'.$str.'</td>
<td>'.$val['products_location'].'</td>
<td>'.$val['actual_stock'].'</td>'.PHP_EOL;
$i++; //序号自增
}
$table.='</table></html>'.PHP_EOL;
echo $table;