public function PHPExcel_Reader_Excel2007::canRead in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php \PHPExcel_Reader_Excel2007::canRead()
* Can the current PHPExcel_Reader_IReader read the file? * *
Parameters
string $pFilename: * @return boolean * @throws PHPExcel_Reader_Exception
Overrides PHPExcel_Reader_Abstract::canRead
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel2007.php, line 78
Class
- PHPExcel_Reader_Excel2007
- PHPExcel_Reader_Excel2007
Code
public function canRead($pFilename) {
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$zipClass = PHPExcel_Settings::getZipClass();
// Check if zip class exists
// if (!class_exists($zipClass, FALSE)) {
// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled");
// }
$xl = false;
// Load file
$zip = new $zipClass();
if ($zip
->open($pFilename) === true) {
// check if it is an OOXML archive
$rels = simplexml_load_string($this
->securityScan($this
->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
if ($rels !== false) {
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 $xl;
}