web 2.0

How to use PHP & Read Multiple Worksheet from excel (Excel.Application)

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

ShotDev Focus:
- PHP  & Read Multiple Worksheet from excel.

PHP & Add Style & Read Multiple Worksheet from excel (Excel.Application)

Example

php_read_multiple.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);
?>
Sheet 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>
<?
$xlSheet2 = $xlBook->Worksheets(2);
?>
Sheet 2
<table width="420" border="1">
<?
$i=1;
while($xlSheet2->Cells->Item($i,1) != "")
{
?>
<tr>
<td><?=$xlSheet2->Cells->Item($i,1);?></td>
<td><?=$xlSheet2->Cells->Item($i,2);?></td>
<td><?=$xlSheet2->Cells->Item($i,3);?></td>
<td><?=$xlSheet2->Cells->Item($i,4);?></td>
<td><?=$xlSheet2->Cells->Item($i,5);?></td>
<td><?=$xlSheet2->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_multiple.php

Screenshot

PHP & Add Style & Read Multiple Worksheet from excel (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.