<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[观夏Note]]></title> 
<link>//gm.angeldm.com/index.php</link> 
<description><![CDATA[新技术番]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[观夏Note]]></copyright>
<item>
<link>//gm.angeldm.com/post//</link>
<title><![CDATA[php使用 PEAR Spreadsheet Excel Writer 创建Excel文档]]></title> 
<author>果面 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[网页相关]]></category>
<pubDate>Tue, 09 Sep 2008 14:58:04 +0000</pubDate> 
<guid>//gm.angeldm.com/post//</guid> 
<description>
<![CDATA[ 
	使用PEAR Spreadsheet_Excel_Writer创建Excel，MS EXCEL不是必需的， OpenOffice Calc也是一个不错的选择。<br/><br/>安装pear:<br/>双击php目录中的go-pear.bat，一路回车安装完毕。<br/>双击PEAR_ENV.reg写入注册表信息。<br/><br/>在命令窗口输入如下命令安装OLE及Spreadsheet_Excel_Writer<br/><br/>$ pear install http://download.pear.php.net/package/OLE-0.5.tgz<br/>$ pear install http://download.pear.php.net/package/Spreadsheet_Excel_Writer-0.9.1.tgz<br/><br/>生成一个简单的电子表格，代码如下：（test.php）<br/><br/><?php<br/>// Include PEAR::Spreadsheet_Excel_Writer<br/>require_once "Spreadsheet/Excel/Writer.php";<br/> <br/>// Create an instance<br/>$xls =& new Spreadsheet_Excel_Writer();<br/> <br/>// Send HTTP headers to tell the browser what's coming<br/>$xls->send("test.xls");<br/> <br/>// Add a worksheet to the file, returning an object to add data to<br/>$sheet =& $xls->addWorksheet('Binary Count');<br/> <br/>// Write some numbers<br/>for ( $i=0;$i<11;$i++ ) &#123;<br/> // Use PHP's decbin() function to convert integer to binary<br/> $sheet->write($i,0,decbin($i));<br/>&#125;<br/> <br/>// Finish the spreadsheet, dumping it to the browser<br/>$xls->close();<br/> <br/>?><br/><br/>在浏览器中输入上面test.php文件所在的地址，就可以用excel或者OpenOffice打开一个电子表格。<br/><br/>将生成的excel文档保存到文件系统。代码如下：<br/><br/><?php<br/> <br/>// 如果文件不存在<br/>if ( !file_exists('sheets/binary.xls') ) &#123;<br/> <br/>// Include PEAR::Spreadsheet_Excel_Writer<br/>require_once "Spreadsheet/Excel/Writer.php";<br/> <br/>// Create an instance, passing the filename to create<br/>$xls =& new Spreadsheet_Excel_Writer('sheets/binary.xls');<br/> <br/>// Add a worksheet to the file, returning an object to add data to<br/>$sheet =& $xls->addWorksheet('Binary Count');<br/> <br/>// Write some numbers<br/> for ( $i=0;$i<11;$i++ ) &#123;<br/>&nbsp;&nbsp; // Use PHP's decbin() function to convert integer to binary<br/>&nbsp;&nbsp; $sheet->write($i,0,decbin($i));<br/> &#125;<br/> <br/>// Finish the spreadsheet, dumping it to the browser<br/>$xls->close();<br/>&#125;<br/> <br/>?><br/><br/>注意，在linux或Unix下，文件所在目录必须可读。<br/>
]]>
</description>
</item><item>
<link>//gm.angeldm.com/read.php?&amp;guid=0#topreply</link>
<title><![CDATA[[评论] php使用 PEAR Spreadsheet Excel Writer 创建Excel文档]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>//gm.angeldm.com/read.php?&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>