小光网络技术博客

介绍和研究搜索引擎优化、SEO、asp、asp.net、php、jsp技术

« 用js+jsp实现拉列表PHP生成带有雪花背景的验证码 »

用Word绘制表格

<?php
$word 
= new COM("word.application") or die("无法启动 Word 程序!"
);

$word->Visible 1
;
$doc $word->Documents->Add
();

$doc->Sections->Add($word->Selection->Range,0);
// 增加一个分节
$Section $doc->Sections(1); 
// 获取第一小节对象
$Range   $Section->Range;   
// 产生 Range 对象
$Table   $doc->Tables->Add($Range ,510); 
// 产生 5x10的表格

// 将数据塞入表格
for ($i=1$i<=10$i
++) {
    for (
$j=1$j<=5$j
++) {
        
$Cell      $Table->Cell($j$i
);
        
$CellRange $Cell->Range
;
        
$CellRange->InsertBefore(chr(0x40+$j).chr(0x40+$i
));
    }
}

$word->Documents[1]->SaveAs("c:\\word.doc"
);
$word->Quit
();
$word->Release
();
$word null
;
?>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Sam

Copyright 2007-2008 小光. Some Rights Reserved.