这几天在用ecshop导出excel,老是出现乱码
注:我的所有文件都是utf-8编码,包括php,htm
php后台代码:header ( "Content-type: application/vnd.ms-excel;" ); //这里只是告诉浏览器要生成xls文件
header ( "Content-Disposition: attachment; filename=test.xls" );  //文件名
$card_list = get_cards ( "c.card_id", $card_ids );  //此处的$card_list为会员卡的数组(该方法此处忽略)
$GLOBALS['smarty']->assign("card_list", $card_list);  //赋值
$table = $GLOBALS['smarty']->fetch('excel_user_card.htm');  //使用ecshop模板文件
echo $table;  //导出之前没有转换为GBK(使用iconv方法)。
exit ();
excel_user_card.htm的代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta name="robots" content="noindex, nofollow" />
<!-- 页面编码为utf-8 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr align="center" bgcolor="#eeeeee">
<td><b>编号</b></td>
<td><b>卡号</b></td>
<td><b>绑定门店</b></td>
</tr>
        <!-- 循环输出行 -->
<!-- {foreach from=$card_list item=card} -->
<tr>
     <td>{$card.card_id}</td>
<td style="vnd.ms-excel.numberformat:@">{$card.card_number}</td>
         <td>{$card.store_re}</td>
</tr>
<!-- {/foreach} -->
</table>
</body>
</html>
ecshop ecxel 乱码