COM function Workbooks->Open($filename) is not working in my code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everybody 
Here the code for reading Excel Sheet what problem with this code is

$Workbook = $excel_app->Workbooks->Open($filename) or Die("Did not
open $filename $Workbook"); 

after creating COM instance workbooks->open Function is not opening
excel sheet.

plz provide some help

<?php
$filename = "Senator.xls";
$sheet1 = 1;
$arr=array(1=>'a','b','c','d','e');
$sheet2 = "sheet2";
$excel_app = new COM("Excel.application") or Die ("Did not connect");
print "Application name: {$excel_app->Application->value}<br>\n" ;
print "Loaded version: {$excel_app->Application->version}<br>\n";
print "file name is".$filename."<br>";
//$excel_app->Application->Visible = 1; #Make Excel visible.
$Workbook = 
 or Die("Did not open $filename $Workbook");
$Worksheet = $Workbook->Worksheets($sheet1);
echo "MALAYAPPA<br>";
$Worksheet->activate;
$excel_cell = $Worksheet->Range("C1");
$excel_cell->activate;
for($i=1; $i<=5;$i++)
{
for($j=1; $j<=5;$j++)
{
$excel_cell = $Worksheet->Range($arr[$i].$j);
echo "<br> The value is $arr[$i].$j => ". $excel_cell->value;
}
}

$excel_result = $excel_cell->value;

$Workbook->Close;
unset($Worksheet);
unset($Workbook);
$excel_app->Workbooks->Close();
$excel_app->Quit();
unset($excel_app);
?>
Reagards
malayappa


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux