Correct way to open a file of unknown format

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


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)?


Mar 9, 2012 at 4: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 9:11 PM


Thanks, Mark