01.
<html>
02.
<head>
03.
<title>ThaiCreate.Com PHP(COM) Excel.Application Tutorial</title>
04.
</head>
05.
<body>
06.
<?
07.
08.
$strPath
=
realpath
(
basename
(
getenv
(
$_SERVER
[
"SCRIPT_NAME"
])));
09.
$OpenFile
=
"MyXls/MyExcelDB.xls"
;
10.
11.
$xlApp
=
new
COM(
"Excel.Application"
);
12.
$xlBook
=
$xlApp
->Workbooks->Open(
$strPath
.
"/"
.
$OpenFile
);
13.
14.
15.
$xlSheet1
=
$xlBook
->Worksheets(1);
16.
?>
17.
<table width=
"420"
border=
"1"
>
18.
<?
for
(
$i
=1;
$i
<=5;
$i
++){?>
19.
<tr>
20.
<td><?=
$xlSheet1
->Cells->Item(
$i
,1);?></td>
21.
<td><?=
$xlSheet1
->Cells->Item(
$i
,2);?></td>
22.
<td><?=
$xlSheet1
->Cells->Item(
$i
,3);?></td>
23.
<td><?=
$xlSheet1
->Cells->Item(
$i
,4);?></td>
24.
</tr>
25.
<?}?>
26.
</table>
27.
<?
28.
29.
$xlApp
->Application->Quit();
30.
$xlApp
= null;
31.
$xlBook
= null;
32.
$xlSheet1
= null;
33.
?>
34.
</body>
35.
</html>