做Excel数据简单的范例

字体大小: 中小 标准 ->行高大小: 标准
一个打开Excel AP制作EXCEL数据的简单范例。

<?
$excel = new COM("Excel.Application") or die("Unable to instanciate Excel"
);

$excel->Visible = 0
;

$book=$excel->Workbooks->Add
;
$book->Title="excel范例"
;
$book->Subject="这是Excel范例程序制作的Excel档"
;

$sheet=$book->Worksheets("Sheet1"
);
$Range=$sheet->Range("A1:C10"
);
For(
$i=1;$i<=10;$i
++):
For(
$j=1;$j<=3;$j
++):
$cell=$Range->Cells($j,$i
);
$cell->value=Chr($i+64).$j;
## 塞入A1:C10的值
EndFor;
EndFor;

$book->SaveAs("c:excel.xls");
## 存档

$excel->Quit
();
$excel->Release
();
$excel = null
;

?>

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/30369.html