openFile($pFilename); if(!$reuslt->isSuccess()){ return ResultWrapper::fail($reuslt->getData(), $reuslt->getErrorCode()); } $readable = $this->isValidFormat(); fclose($this->fileHandle); return ResultWrapper::success($readable); } /** * Open file for reading * * @param string $pFilename * @return ResultWrapper */ protected function openFile($pFilename) { // Check if file exists if (!file_exists($pFilename) || !is_readable($pFilename)) { return ResultWrapper::fail('文件不存在',$pFilename, ErrorCode::$notAllowAccess); } // Open file $this->fileHandle = fopen($pFilename, 'r'); if ($this->fileHandle === false) { return ResultWrapper::fail('读取文件失败',$pFilename, ErrorCode::$notAllowAccess); } } /** * 获取只读取数据模式配置 * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. * If false (the default) it will read data and formatting. * * @return boolean */ public function getReadDataOnly() { return $this->readDataOnly; } /** * 设置是否只读取数据 * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. * Set to false (the default) to advise the Reader to read both data and formatting for cells. * * @param boolean $pValue * * @return PHPExcel_Reader_IReader */ public function setReadDataOnly($pValue = false) { $this->readDataOnly = $pValue; return $this; } /** * Scan theXML for use of readFilter; } /** * Set read filter * * @param PHPExcel_Reader_IReadFilter $pValue * @return PHPExcel_Reader_IReader */ public function setReadFilter(IReadFilter $pValue) { $this->readFilter = $pValue; return $this; } /** * Get which sheets to load * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null * indicating that all worksheets in the workbook should be loaded. * * @return mixed */ public function getLoadSheetsOnly() { return $this->loadSheetsOnly; } /** * Set which sheets to load * * @param mixed $value * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. * If NULL, then it tells the Reader to read all worksheets in the workbook * * @return PHPExcel_Reader_IReader */ public function setLoadSheetsOnly($value = null) { if ($value === null) { return $this->setLoadAllSheets(); } $this->loadSheetsOnly = is_array($value) ? $value : array($value); return $this; } /** * Set all sheets to load * Tells the Reader to load all worksheets from the workbook. * * @return PHPExcel_Reader_IReader */ public function setLoadAllSheets() { $this->loadSheetsOnly = null; return $this; } }