首页 > php教程 > php手册 > 正文

生成excel的文件

WBOY
发布: 2016-06-21 09:05:49
原创
1050 人浏览过

excel|生成excel


header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");


$sql = "select ";
if ( $HTTP_POST_VARS["C1"] == "ON" ) $sql .= "hdid, ";
if ( $C2 == "ON" ) $sql .= "location, ";
if ( $C3 == "ON" ) $sql .= "getip, ";
if ( $C4 == "ON" ) $sql .= "type, ";
if ( $C5 == "ON" ) $sql .= "pcusername, ";
if ( $C6 == "ON" ) $sql .= "usergroup, ";
if ( $C7 == "ON" ) $sql .= "ram, ";
if ( $C8 == "ON" ) $sql .= "cpu, ";
if ( $C9 == "ON" ) $sql .= "disk, ";
if ( $C10 == "ON" ) $sql .= "lanmac, ";
if ( $C11 == "ON" ) $sql .= "monitor, ";
if ( $C12 == "ON" ) $sql .= "attachhd, ";
if ( $C13 == "ON" ) $sql .= "software, ";
if ( $C14 == "ON" ) $sql .= "weblog, ";
if ( $C15 == "ON" ) $sql .= "other ";

if ( substr($sql, -2) == ", " ) $sql = substr($sql, 0, strlen($str)-2) . " ";

$sql .= "from pcinfo order by hdid asc";

$link = mysql_connect('127.0.0.1','root','0000') or die("無法連線!請連絡管理者!");

mysql_select_db('hdinfo',$link) or die("無法連到資料庫!請連絡管理者!");

//echo $sql;

$result = mysql_query("$sql");

$total=mysql_num_rows($result);

//echo $total;

if ( $HTTP_POST_VARS["C1"] == "ON" ) echo "硬件编号\t";
if ( $C2 == "ON" ) echo "所属厂别\t";
if ( $C3 == "ON" ) echo "所分配的IP\t";
if ( $C4 == "ON" ) echo "机器型号\t";
if ( $C5 == "ON" ) echo "使用者名称\t";
if ( $C6 == "ON" ) echo "使用者部门\t";
if ( $C7 == "ON" ) echo "内存配置\t";
if ( $C8 == "ON" ) echo "CPU配置\t";
if ( $C9 == "ON" ) echo "硬盘配置\t";
if ( $C10 == "ON" ) echo "网卡型号及MAC\t";
if ( $C11 == "ON" ) echo "显示器型号\t";
if ( $C12 == "ON" ) echo "其所附的硬件\t";
if ( $C13 == "ON" ) echo "所安装的软件\t";
if ( $C14 == "ON" ) echo "上网申请纪录\t";
if ( $C15 == "ON" ) echo "其他\t";
echo " \t\n";

for ($i=0 ;$i{
$result_row=mysql_fetch_row($result);
while (list($no,$content)=each($result_row))
{
echo "$content\t";
}
echo " \t\n";
}

以上是根据不同的选项查询不同的列,然后生成Excel 的文件



相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!