SEO対策
SEO BLOG | SEO 博客 | SEO ブログ

php生成excel ExcelWriterXML

一个用php生成excel的类库,生成的格式为xml,非常简单并且好用!Set of classes for PHP that allow Excel XML files to be generated dynamically. Nearly a full implementation of the MS XML architecture. Requires PHP 5+ Does not require any XML libraries.



生成的excel是xml格式,用office2003/2007,openoffice全都能打开。
这个类库共有三个文件:
ExcelWriterXML.php Class for generating the initial Excel XML document
ExcelWriterXML_Sheet.php Class for generating sheets within the Excel document
ExcelWriterXML_Style.php Style class for generating Excel styles

生成excel过程简要描述:

$xml = new ExcelWriterXML; //生成一个xml的excel
$xml->docAuthor('Robert F Greer'); //写入作者

$format = $xml->addStyle('StyleHeader'); //生成一个样式
$format->fontBold(); //字体加粗
$format->alignRotate(45); //旋转45度
$sheet = $xml->addSheet('My Sheet'); //加入一张表

$sheet->writeString(1,1,'Header','StyleHeader'); //以StyleHeader的样式在第一行第一列写入文字
$sheet->writeString(2,1,'Test String','StyleHeader');//以StyleHeader的样式在第二行第一列写入文字

$xml->sendHeaders();//输出http header
$xml->writeData();//写出xml


这个类库不能设置页边距,如果想改的话,只能自己修改类库,或在输出出来的xml上修改

附上页边距修改的xml:

<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0"/>
<Footer x:Margin="0"/>
<PageMargins x:Bottom="0.19685039370078741" x:Left="0.94488188976377963" x:Right="0.94488188976377963" x:Top="0.19685039370078741"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<Scale>86</Scale>
<HorizontalResolution>-3</HorizontalResolution>
<VerticalResolution>0</VerticalResolution>
</Print>
</WorksheetOptions>


下载地址:http://excelwriterxml.sourceforge.net/

2009-05-14 10:39:55 のブログ記事


twitter

开始看雷蒙德·卡佛的短篇集。。。

日本来中国留学说明

Rss Space

等待touch3破解,geohot is real man

cts-v这汽车真是太猛了!!!!

终于拿到了签证.....

雅歌塔克里斯多夫的《第三谎言》,已经看完了

两个前轮胎换成了普利司通的了,后面两个什么时候才能换呢????

在女朋友的允许下我终于买了ndsi

It was the best of times. It was the worst of times --《A Tale of Two Cities》

《神经浪游者》阅读到第18页。。。。没时间看了。。。可能再也看不完了

Philip Kindred Dick的《Minority Report》已经看完了。。。。。