having trouble in opening .xlsx file

Topics: Developer Forum, Project Management Forum, User Forum
Nov 12, 2012 at 1:12 PM

I am unable of open .xslx file, here is the Error Message when i try to open .xlsx :


Fatal error: Uncaught exception 'Exception' with message 'The filename inspection_1.xlsx is not recognised as an OLE file' in D:\wamp\www\PHPExcell\Classes\PHPExcel\Shared\OLERead.php:87 Stack trace: #0 D:\wamp\www\PHPExcell\Classes\PHPExcel\Reader\Excel5.php(1182): PHPExcel_Shared_OLERead->read('inspection_1.xl...') #1 D:\wamp\www\PHPExcell\Classes\PHPExcel\Reader\Excel5.php(689): PHPExcel_Reader_Excel5->_loadOLE('inspection_1.xl...') #2 D:\wamp\www\PHPExcell\my_example.php(31): PHPExcel_Reader_Excel5->load('inspection_1.xl...') #3 {main} thrown in D:\wamp\www\PHPExcell\Classes\PHPExcel\Shared\OLERead.php on line 87


Please guide me on this issue.


Nov 12, 2012 at 1:16 PM

are you sure the file is a valid xlsx file? (ie, not just an html file saved with an xlsx extension). unzip the file, and/or open the file in a text editor

Nov 12, 2012 at 1:21 PM

yes its a valid xlsx file, because when i saved same file as xls, its opened successfully.

Nov 12, 2012 at 1:25 PM

if you saved another file in a different format, you could open it, and therefore this file must be a valid xlsx file? I think your logic is flawed ;)


What program do you use to create the .xlsx file?

Nov 12, 2012 at 1:29 PM

Its been created using MS Excel 2010

Nov 12, 2012 at 1:30 PM

alrighty, then it should work! can you share the code you use to open the file?

Nov 12, 2012 at 1:32 PM

its not even opening xlsx files that are being used as example in downloaded library :)

Nov 12, 2012 at 1:39 PM

I have fixed the issue :)

It was file type issue, I was using Excel5, just changed it to Excel2007 and its working now for xlsx ..

Is there anyway so that we can set it to open either .xls or .xlsx ?

Nov 12, 2012 at 1:43 PM
Edited Nov 12, 2012 at 1:43 PM

Also, I am unable to fetch photos when using .xlsx

but when i use .xls file i can fetch photos from Excel file using following code:



//------ Following is used to fetch and save images
$count = 1;
foreach ($objPHPExcel->getSheetByName("Photographs")->getDrawingCollection() as $drawing) {
	if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
		$imageContents = ob_get_contents();
		//Save graph image
		$fp = @fopen("picture".$count.".png" , "w");
		@fwrite($fp , $imageContents);

do you know how we can fetch other objects from XLS like 'MS Word' ?
Nov 12, 2012 at 2:07 PM

For automatically reading different type files:

  if (empty($FileName)) {
    throw new Exception("No file specified.");

  if (!file_exists($FileName)) {
    throw new Exception("Could not open " . $FileName . " for reading! File does not exist.");

  try {
    $FileType = PHPExcel_IOFactory::identify($FileName);
    $SpreadsheetReaderObj = PHPExcel_IOFactory::createReader($FileType);
    switch ($FileType) {
      case 'Excel2007':
      case 'Excel2003XML':
      case 'Excel5':
      case 'OOCalc':
      case 'SYLK':
      case 'CSV':
  } catch (Exception $ExceptionObj) {
    // Exception Error Handling

Nov 12, 2012 at 2:51 PM


Do you know how we can export other objects from XLS, I have successfully export pictures from .xls but unable to export from .xlsx though. Is there any specific parameters required to fetch pictures from .xlsx ?

Also I am trying to export MS Word object from XLS, but I am unable to fetch MS Word object ( embed through Insert->Object into XLS ).

Is there any way to fetch included MS Word object ?


Aug 5, 2014 at 6:09 AM
I even have the same kind of error for .xls files and for .xlsx files as well.
I solved it for .xls files, and the files are getting converted efficiently to csv format (that contains multiple sheets of .xls files).
Feel free to get in touch with me in case the error is still alive.