search
Homephp教程php手册生成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 的文件



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),