How to check excel file version?

Topics: User Forum
Nov 17, 2010 at 6:26 PM
Edited Nov 17, 2010 at 6:50 PM

I'm new to phpexcel. I have one question about excel file version. I create a page that user uploads excel file to my server. I don't know how to check uploaded file version, so I don't know what reader's version to read this file. Is there any function to check excel file version?

I tested with one excel file, error took place 'Cannot read encrypted file.' I tried reader from excel5, excel2003xml to excel2007 with no success. I had to convert this file to excel 5 format. I could read this file with 'excel5' reader.

Thank you.

Coordinator
Nov 18, 2010 at 8:56 AM

Either use

$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);

which will try to identify the filetype automatically, and load the file using the appropriate loader in a single step

or

$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);

which identifies the reader to use for a the file, instantiates a reader of the identified type, then loads the file

re: "Cannot read encrypted file"

It's pretty self-explanatory: PHPExcel cannot read Excel files that are encrypted.

Nov 18, 2010 at 10:30 AM
Edited Nov 18, 2010 at 10:50 AM

Thank you, Mark.  I didn't usually play with office.  I don't know what 'encrypted file' means. I can open it with OpenOffice with no special work. The file is protected for being edited but can be read. As I asked above, if I convert it to excel 5 (without changing any protection), reader can read it.