生成excel的文件
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 的文件
上一篇: js简介及基本入门
下一篇: 选择MySQL正确的安装包_MySQL
推荐阅读
-
如何修改文件夹的创建日期有哪些方法
-
用VB生成DLL封装ASP连接数据库的代码
-
SQL Server利用bcp命令把SQL语句结果生成文本文件
-
jquery获取file表单选择文件的路径、名字、大小、类型
-
IE浏览器缓存所存放的文件夹怎么更换?
-
myeclipse误删的项目文件怎么找回?
-
Android studio怎么创建文件? 添加activity文件的教程
-
Android studio怎么将本地要更改的文件移至changelist中?
-
Android studio怎么创建文件? Android studio新建Java类文件的方法
-
Android studio怎么创建资源的相关文件编辑xml?