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 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:
You might also enjoy:
-
If you are busy writing a macro for Excel and want to figure out the number of rows currently being used for some sort of calculation that you want to run a ...
-
The CodePlex project PHPExcel is an absolutely brilliant implementation around Microsoft's OpenXML standard, giving us a powerful PHP object driven engine t ...
-
For the quickest implementation time in terms of churning out Excel 2007 spreadsheets in your PHP-based project, look no further than the brilliant PHPExcel ...
-
PHPExcel is a phenomenal Excel generating library for PHP which I have mentioned on this site numerous times before, and which is currently my defacto way f ...
-
The CodePlex project PHPExcel is an absolutely brilliant implementation around Microsoft's OpenXML standard, giving us a powerful PHP object driven engine t ...