public function PHPExcel_Reader_Excel2003XML::canRead in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php \PHPExcel_Reader_Excel2003XML::canRead()
* Can the current PHPExcel_Reader_IReader read the file? * *
Parameters
string $pFilename: * @return boolean * @throws PHPExcel_Reader_Exception
Overrides PHPExcel_Reader_Abstract::canRead
2 calls to PHPExcel_Reader_Excel2003XML::canRead()
- PHPExcel_Reader_Excel2003XML::listWorksheetNames in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel2003XML.php - * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * *
- PHPExcel_Reader_Excel2003XML::loadIntoExisting in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel2003XML.php - * Loads PHPExcel from file into PHPExcel instance * *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel2003XML.php, line 77
Class
- PHPExcel_Reader_Excel2003XML
- PHPExcel_Reader_Excel2003XML
Code
public function canRead($pFilename) {
// Office xmlns:o="urn:schemas-microsoft-com:office:office"
// Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
// XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
// Spreadsheet component xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
// XML schema xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
// XML data type xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
// MS-persist recordset xmlns:rs="urn:schemas-microsoft-com:rowset"
// Rowset xmlns:z="#RowsetSchema"
//
$signature = array(
'<?xml version="1.0"',
'<?mso-application progid="Excel.Sheet"?>',
);
// Open file
$this
->_openFile($pFilename);
$fileHandle = $this->_fileHandle;
// Read sample data (first 2 KB will do)
$data = fread($fileHandle, 2048);
fclose($fileHandle);
$valid = true;
foreach ($signature as $match) {
// every part of the signature must be present
if (strpos($data, $match) === false) {
$valid = false;
break;
}
}
// Retrieve charset encoding
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um', $data, $matches)) {
$this->_charSet = strtoupper($matches[1]);
}
// echo 'Character Set is ',$this->_charSet,'<br />';
return $valid;
}