Additional validation check in the canLoad() method of Excel2007 Reader to return false for OpenXML documents that aren't workbooks (eg. pptx, docx)

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@64373 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-11-26 00:36:01 +00:00
parent f2bed9ca37
commit fcf2643609
1 changed files with 11 additions and 3 deletions

View File

@ -168,18 +168,26 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$xl = false;
// Load file
$zip = new ZipArchive;
if ($zip->open($pFilename) === true) {
// check if it is an OOXML archive
$rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"));
foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
if (basename($rel["Target"]) == 'workbook.xml') {
$xl = true;
}
break;
}
}
$zip->close();
return ($rels !== false);
}
return false;
return $xl;
}
private function _castToBool($c) {