<?php
header("Content-Type:text/html;charset=utf-8"); //设置字体编码,避免中文乱码
require_once("db_config.php");
?>
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
$sql="SELECT * FROM RetailersInfoTable";
$rs=mysql_query($sql);
// 输出内容如下:
echo iconv("UTF-8", "GBK", "网点编号")."\t"; //避免导出中文乱码
echo iconv("UTF-8", "GBK", "网点名称")."\t";
echo iconv("UTF-8", "GBK", "网点地址")."\t";
echo "\n";
while ($rows=mysql_fetch_assoc($rs))
{
$rename=$rows["RetailersName"];
$add=$rows["RetailersAddress"];
echo $rows["RetailersID"]."\t";
echo iconv("UTF-8", "GBK", $rename)."\t";
echo iconv("UTF-8", "GBK", $add)."\t";
echo "\n";
}
?>
PHP导出Excel表格(最简易)
最新推荐文章于 2024-01-19 09:00:00 发布