有没有好点的生成Excel的类啊 本博里找吧:http://qsy_627.blog.163.com 绝对够专业,方便。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?phpclass Excel_XML{ private $header = "<?xml version=\"1.0\" encoding=\"gb2312\"?\><Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">"; private $footer = "</Workbook>"; private $lines = array (); private $worksheet_title = "Table1"; private function addRow ($array) { $cells = ""; foreach ($array as $k => $v): $cells .= "<Cell><Data ss:Type=\"String\">" . $v . "</Data></Cell>\n"; endforeach; $this->lines[] = "<Row>\n" . $cells . "</Row>\n"; } public function addArray ($array) { // run through the array and add them into rows foreach ($array as $k => $v): $this->addRow ($v); endforeach; } public function setWorksheetTitle ($title) { // strip out special chars first $title = preg_replace ("/[\\\|:|\/|\?|\*|\[|\]]/", "", $title); // now cut it to the allowed length $title = substr ($title, 0, 31); // set title $this->worksheet_title = $title; } function generateXML ($filename) { // deliver header (as recommended in php manual) header("Content-Type: application/vnd.ms-excel; charset=gb2312"); header("Content-Disposition: inline; filename=\"" . $filename . ".xls\""); // print out document to the browser // need to use stripslashes for the damn ">" echo stripslashes ($this->header); echo "\n<Worksheet ss:Name=\"" . $this->worksheet_title . "\">\n<Table>\n"; echo "<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n"; echo implode ("\n", $this->lines); echo "</Table>\n</Worksheet>\n"; echo $this->footer; }}?>//调用require ("class-excel-xml.inc.php");$xls = new Excel_XML();/*$_docTitle = array ( 1 => array ( "编号", "姓名","性别", "单位", "分站点", "必修课版次", "总学时", "作业完成数", "作业合格数", "作业总评", "论文题目", "论文成绩", "学习总评", "注册情况","注册时间") );*/$xls->addArray($_docTitle);$xls->addArray($_userdataimportdb);$xls->generateXML($setname);//*/ php,数据库读取错行加减法及进行合计问题 不明白php中的inet_pton的返回值是什么? html页面如何向后台php文件传参 请问这段代码为什么不能控制 问很弱智问题 为自己企业用户郡发资料问题. 我是新手,问个很初级的问题! 我在vc下作开发有一年多了,痛恨ms的垄断,不知道学习php是否可以摆脱受人制约的感觉,同时想问php有前途吗,听说她的问题很多?! PHP的十个高级技巧之八——PHP和Java 页面之间变量的传递一直是一个比较困惑的问题,通常情况的处理办法以及有哪些特殊情况能帮我解决一下吗? 有没有好点的生成Excel的类啊 这样的文件格式怎么提取数据
<?php
class Excel_XML
{
private $header = "<?xml version=\"1.0\" encoding=\"gb2312\"?\>
<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"
xmlns:x=\"urn:schemas-microsoft-com:office:excel\"
xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"
xmlns:html=\"http://www.w3.org/TR/REC-html40\">"; private $footer = "</Workbook>";
private $lines = array ();
private $worksheet_title = "Table1"; private function addRow ($array)
{
$cells = "";
foreach ($array as $k => $v): $cells .= "<Cell><Data ss:Type=\"String\">" . $v . "</Data></Cell>\n"; endforeach;
$this->lines[] = "<Row>\n" . $cells . "</Row>\n"; } public function addArray ($array)
{ // run through the array and add them into rows
foreach ($array as $k => $v):
$this->addRow ($v);
endforeach; } public function setWorksheetTitle ($title)
{ // strip out special chars first
$title = preg_replace ("/[\\\|:|\/|\?|\*|\[|\]]/", "", $title); // now cut it to the allowed length
$title = substr ($title, 0, 31); // set title
$this->worksheet_title = $title; } function generateXML ($filename)
{ // deliver header (as recommended in php manual)
header("Content-Type: application/vnd.ms-excel; charset=gb2312");
header("Content-Disposition: inline; filename=\"" . $filename . ".xls\""); // print out document to the browser
// need to use stripslashes for the damn ">"
echo stripslashes ($this->header);
echo "\n<Worksheet ss:Name=\"" . $this->worksheet_title . "\">\n<Table>\n";
echo "<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n";
echo implode ("\n", $this->lines);
echo "</Table>\n</Worksheet>\n";
echo $this->footer; }}
?>//调用
require ("class-excel-xml.inc.php");$xls = new Excel_XML();/*
$_docTitle = array (
1 => array (
"编号", "姓名","性别", "单位", "分站点",
"必修课版次", "总学时", "作业完成数", "作业合格数",
"作业总评", "论文题目", "论文成绩", "学习总评", "注册情况","注册时间")
);
*/$xls->addArray($_docTitle);
$xls->addArray($_userdataimportdb);
$xls->generateXML($setname);
//*/