web 2.0

How to use PHP & Read excel file (Excel.Application)

How to use PHP & Read excel file (Excel.Application) The Learn / tutorial php programming how to using  PHP Read excel file.

ShotDev Focus:
- PHP  & Read excel file.

PHP & Add Style & Read excel file (Excel.Application)

Example

php_read_excel.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
//*** Get Document Path ***//
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
$OpenFile = "MyXls/MyExcelDB.xls";
//*** Create Excel.Application ***//
$xlApp = new COM("Excel.Application");
$xlBook = $xlApp->Workbooks->Open($strPath."/".$OpenFile);
//$xlBook = $xlApp->Workbooks->Open(realpath($OpenFile));

$xlSheet1 = $xlBook->Worksheets(1);
?>
<table width="420" border="1">
<?
$i=1;
while($xlSheet1->Cells->Item($i,1) != "")
{
?>
<tr>
<td><?=$xlSheet1->Cells->Item($i,1);?></td>
<td><?=$xlSheet1->Cells->Item($i,2);?></td>
<td><?=$xlSheet1->Cells->Item($i,3);?></td>
<td><?=$xlSheet1->Cells->Item($i,4);?></td>
<td><?=$xlSheet1->Cells->Item($i,5);?></td>
<td><?=$xlSheet1->Cells->Item($i,6);?></td>
</tr>
<?
$i = $i + 1;
}
?>
</table>
<?
//*** Close & Quit ***//
$xlApp->Application->Quit();
$xlApp = null;
$xlBook = null;
$xlSheet1 = null;
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_read_excel.php

Screenshot

PHP & Add Style & Read excel file (Excel.Application)
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.