From 3d3543cb179ce351d6ae5a48f655c31b8ce8a3af Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 3 Jan 2013 17:49:56 +0000 Subject: [PATCH] Bugfix: Work item GH-113 - canRead() Error for GoogleDocs ODS files: in ODS files from Google Docs there is no mimetype file --- Classes/PHPExcel/Reader/OOCalc.php | 17 ++++++++++++++--- changelog.txt | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index 7296d819..d0c931a1 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -79,6 +79,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce throw new PHPExcel_Reader_Exception("ZipArchive library is not enabled"); } + $mimeType = 'UNKNOWN'; // Load file $zip = new ZipArchive; if ($zip->open($pFilename) === true) { @@ -86,9 +87,19 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $stat = $zip->statName('mimetype'); if ($stat && ($stat['size'] <= 255)) { $mimeType = $zip->getFromName($stat['name']); - } else { - $zip->close(); - return FALSE; + } elseif($stat = $zip->statName('META-INF/manifest.xml')) { + $xml = simplexml_load_string($zip->getFromName('META-INF/manifest.xml')); + $namespacesContent = $xml->getNamespaces(true); + if (isset($namespacesContent['manifest'])) { + $manifest = $xml->children($namespacesContent['manifest']); + foreach($manifest as $manifestDataSet) { + $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']); + if ($manifestAttributes->{'full-path'} == '/') { + $mimeType = (string) $manifestAttributes->{'media-type'}; + break; + } + } + } } $zip->close(); diff --git a/changelog.txt b/changelog.txt index 4f7cb71e..4d4668b1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -46,6 +46,7 @@ Fixed in develop branch: - Bugfix: (teso) Work item 18551 - Rich Text containing UTF-8 characters creating unreadable content with Excel5 Writer - Bugfix: (MBaker) Work item GH-104 - echo statements in HTML.php - Feature: (Progi1984) Work item GH-8/CP11704 : Conditional formatting in Excel 5 Writer +- Bugfix: (MBaker) Work item GH-113 - canRead() Error for GoogleDocs ODS files: in ODS files from Google Docs there is no mimetype file --------------------------------------------------------------------------------