For a long time there has been the excellent SourceForge Excel Reader PHP class available to developers wishing to add Excel parsing to their offerings, but unfortunately active development on the code stopped absolutely months ago already.
Thankfully for us though, a guy by the name of Matt Kruse picked up this dropped project, put it up on Google Code and continued to update and make the code a little bit more usable in the process.
Implementing Excel parsing (only up to Office 2003 format, i.e. .xls files) is as simple as including a single file and then pointing a valid Excel document at its constructor function:
$data = new Spreadsheet_Excel_Reader(“test.xls”);
From there it is a matter of accessing the spreadsheet data by using a number of methods available to you. For example, to retrieve formatted value of a cell you have the following options available to you:
Retrieve formatted value of cell (first or only sheet):
$data->val($row,$col)
Or using column names:
$data->val(10,‘AZ’)
From a sheet other than the first:
$data->val($row,$col,$sheet_index)
You can also retrieve cell info such as:
$data->type($row,$col);
$data->raw($row,$col);
$data->format($row,$col);
$data->formatIndex($row,$col);
or get the active sheet size:
$data->rowcount();
$data->colcount();
There’s a fair bit of functionality available to you, all neatly stored in the help documentation, meaning that now there is absolutely no excuse for not supporting Excel spreadsheet parsing in your PHP projects any more! :P
Related Link: http://code.google.com/p/php-excel-reader/