What are the common pitfalls when trying to open Excel files using PHP and COM objects?

Common pitfalls when trying to open Excel files using PHP and COM objects include not having the correct permissions set on the server, not having the COM extension enabled in PHP, and not properly handling errors that may occur during the file opening process.

<?php
$excel = new COM("Excel.Application") or die("Unable to instantiate Excel");
$excel->Visible = 1;
$workbook = $excel->Workbooks->Open("C:\\path\\to\\file.xlsx");

// Rest of your code to work with the Excel file

$workbook->Close(false);
$excel->Quit();
$excel = null;
?>