http://cn.php.net/manual/en/class.com.php -------------------------------------------------------- I have searched for ways to open and read an excel document and I found some information which I thought that I would document. Information on the object model to help with programming COM objects can be found in your MS Office help files, search for VBA*.chm. Also, here is a script that I used to pull a cell from each worksheet, complete w/ variable for pathnames & worksheets. This script also closes excel completely. The coding might be dirty, but it gets the job done. --------copy from here----------- <pre> <?PHP $filename = "c:/spreadhseet/test.xls"; $sheet1 = 1; $sheet2 = "sheet2"; $excel_app = new COM("Excel.application") or Die ("Did not connect"); print "Application name: {$excel_app->Application->value}\n" ; print "Loaded version: {$excel_app->Application->version}\n"; $Workbook = $excel_app->Workbooks->Open("$filename") or Die("Did not open $filename $Workbook"); $Worksheet = $Workbook->Worksheets($sheet1); $Worksheet->activate; $excel_cell = $Worksheet->Range("C4"); $excel_cell->activate; $excel_result = $excel_cell->value; print "$excel_result\n"; $Worksheet = $Workbook->Worksheets($sheet2); $Worksheet->activate; $excel_cell = $Worksheet->Range("C4"); $excel_cell->activate; $excel_result = $excel_cell->value; print "$excel_result\n"; #To close all instances of excel: $Workbook->Close; unset($Worksheet); unset($Workbook); $excel_app->Workbooks->Close(); $excel_app->Quit(); unset($excel_app); ?> </pre>
--------------------------------------------------------
I have searched for ways to open and read an excel document and I found some information which I thought that I would document. Information on the object model to help with programming COM objects can be found in your MS Office help files, search for VBA*.chm.
Also, here is a script that I used to pull a cell from each worksheet, complete w/ variable for pathnames & worksheets. This script also closes excel completely. The coding might be dirty, but it gets the job done.
--------copy from here-----------
<pre>
<?PHP
$filename = "c:/spreadhseet/test.xls";
$sheet1 = 1;
$sheet2 = "sheet2";
$excel_app = new COM("Excel.application") or Die ("Did not connect");
print "Application name: {$excel_app->Application->value}\n" ;
print "Loaded version: {$excel_app->Application->version}\n";
$Workbook = $excel_app->Workbooks->Open("$filename") or Die("Did not open $filename $Workbook");
$Worksheet = $Workbook->Worksheets($sheet1);
$Worksheet->activate;
$excel_cell = $Worksheet->Range("C4");
$excel_cell->activate;
$excel_result = $excel_cell->value;
print "$excel_result\n";
$Worksheet = $Workbook->Worksheets($sheet2);
$Worksheet->activate;
$excel_cell = $Worksheet->Range("C4");
$excel_cell->activate;
$excel_result = $excel_cell->value;
print "$excel_result\n";
#To close all instances of excel:
$Workbook->Close;
unset($Worksheet);
unset($Workbook);
$excel_app->Workbooks->Close();
$excel_app->Quit();
unset($excel_app);
?>
</pre>