Correct way to open a file of unknown format

Topics: User Forum
Mar 9, 2012 at 2:04 PM

Hello,

what is your advice about how to open a generic spreadsheet file, of unknown format?

A "switch" construct on the file extension, together with "canRead" method calls when the extension is not enough to determine which reader to instantiate (ex: .XLS)?

Thanks

Coordinator
Mar 9, 2012 at 5:40 PM

The static identify() method of the PHPExcel_IOFactory class will return the name of the reader that should be used for loading a file of unknown format... it can detect (for example) csv files with a .xls extension.

 

There's a nice example of how to use it in this thread

Mar 9, 2012 at 10:11 PM

Perfect.

Thanks, Mark