You are here

public function PHPExcel_Reader_Gnumeric::canRead in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Gnumeric.php \PHPExcel_Reader_Gnumeric::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/Gnumeric.php, line 80

Class

PHPExcel_Reader_Gnumeric
PHPExcel_Reader_Gnumeric

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.");
  }

  // Check if gzlib functions are available
  if (!function_exists('gzread')) {
    throw new PHPExcel_Reader_Exception("gzlib library is not enabled");
  }

  // Read signature data (first 3 bytes)
  $fh = fopen($pFilename, 'r');
  $data = fread($fh, 2);
  fclose($fh);
  if ($data != chr(0x1f) . chr(0x8b)) {
    return false;
  }
  return true;
}