PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

Reading a XLSX-File fails #50

Closed donajena closed 7 years ago

donajena commented 11 years ago

Hello there!

I try to read a XLSX-File with following code: $inputFileType = PHPExcel_IOFactory::identify($inputFileName); /\ Create a new Reader of the type that has been identified / $objReader = PHPExcel_IOFactory::createReader($inputFileType); / Load $inputFileName to a PHPExcel Object **/ $objPHPExcel = $objReader->load($inputFileName);

It works fine for Excel2007 files if I create them with Excel.

Now I want to read XLXS files from Suunto movescount.com. You can download XLSX-Files from movescount and save them on harddisk. If I want to read them, I have to open them first with Excel and then save again.

If I do not open with Excel and save again, I can not read these files. Has anybody a solution or idea?

Thanks, Dominik

MarkBaker commented 11 years ago

Is there any particular reason why you can't open files from Suunto movescount.com directly? Any errors thrown? Any missing data? Are they actually OfficeOpenXML files? What does identify() return? Any clues whatsoever?

rsulzenbacher commented 11 years ago

Hello!

I have the same problem. Can't open movescount .xlsx file directly with PHPExcel... Problem is getSheetCount delivers 0 and of course no worksheets are available.

Funny thing aside: Apple Numbers can't open it either. "No valid Excel file!"

I don't really understand which "Excel" format Suunto is using.

Richard

rsulzenbacher commented 11 years ago

It looks like OfficeOpenXML (when I open it with Texteditor) and identify delivers "Excel2007".

ultrinnan commented 7 years ago

This is because downloaded file is in HTML format (but names as .xmlx)

rijoshrc commented 7 years ago

I did the following steps to fix this.

$inputFileName = 'test.xlsx'; $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objReader->setReadDataOnly(true); $objPHPExcel = $objReader->load($inputFileName);

Install the ZipArchive if not already installed sudo apt-get install php7.0-zip sudo service apache2 restart