Hi!
Long time no post, mostly because I've had to put the mobile coding aside for my real job. Plus some home brewing. And lots of pinball.
I have run into a problem. I am developing an application where an Excel spreadsheet (or tab-delimited text file) can be read in and used as data with the MySQL. This works, except:
I want to be able to start with the Excel2007 reader against the imported Excel spreadsheet. If this fails then the Excel5 reader can generally read anything the Excel2007 reader can't.
My big problem is there doesn't seem to be a graceful way of evaluating this. I'm currently trying something like this:
if (($new_ext=="xls") or ($new_ext=="xlsx")) {
try {
$objReader=PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel=$objReader->load($uploadFilename); }
catch (Exception $e) {
$objReader=PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel=$objReader->load($uploadFilename); } }
Invoking the reader doesn't cause the error, loading it does.
Short of just analyzing the first 128 bytes of the file, is there a way to try another reader if another one fails?
Thanks!
Steve
PS: If you're in Seattle, send me a message and we'll geek out over beer and pinball.