@param string $file
@param string $sheet
@param string $range
@param int    $offset
@param int    $limit

@return array

@throws \MercesLab\Component\SpreadsheetClient\Exception\ReadRequestFailedException
349074
protected function doRead(
        string $file,
        string $sheet,
        string $range,
        int $offset = ClientInterface::DEFAULT_OFFSET,
        int $limit = ClientInterface::DEFAULT_LIMIT
    ): array {
        try {
            $range = $this->getPageRange($range, $offset, $limit);
            $googleFile = $this->googleServiceSheets->spreadsheets_values->get(
                $file,
                $this->getTableRange($sheet, $range)
            );

            return $googleFile->getValues();
        } catch (\Google_Exception $e) {
            throw new ReadRequestFailedException(
                "Failed reading data from GoogleSpreadsheet (file: {$file}, sheet: {$sheet}, table: {$range}).",
                500,
                $e
            );
        }
    }
1020875
public function listWorksheetInfo($pFilename)
	{
		// Check if file exists
		if (!file_exists($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
		}

		$worksheetInfo = array();

		$zip = new ZipArchive;
		if (!$zip->open($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
		}

		$xml = new XMLReader();
		$res = $xml->open('zip://'.realpath($pFilename).'#content.xml');
		$xml->setParserProperty(2,true);

		//	Step into the first level of content of the XML
		$xml->read();
		while ($xml->read()) {
			//	Quickly jump through to the office:body node
			while ($xml->name !== 'office:body') {
				if ($xml->isEmptyElement)
					$xml->read();
				else
					$xml->next();
			}
				//	Now read each node until we find our first table:table node
			while ($xml->read()) {
				if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
					$worksheetNames[] = $xml->getAttribute('table:name');

					$tmpInfo = array(
						'worksheetName' => $xml->getAttribute('table:name'),
						'lastColumnLetter' => 'A',
						'lastColumnIndex' => 0,
						'totalRows' => 0,
						'totalColumns' => 0,
					);

					//	Loop through each child node of the table:table element reading
					$currCells = 0;
					do {
						$xml->read();
						if ($xml->name == 'table:table-row' && $xml->nodeType == XMLReader::ELEMENT) {
							$rowspan = $xml->getAttribute('table:number-rows-repeated');
							$rowspan = empty($rowspan) ? 1 : $rowspan;
							$tmpInfo['totalRows'] += $rowspan;
							$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
							$currCells = 0;
							//	Step into the row
							$xml->read();
							do {
								if ($xml->name == 'table:table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
									if (!$xml->isEmptyElement) {
										$currCells++;
										$xml->next();
									} else {
										$xml->read();
									}
								} elseif ($xml->name == 'table:covered-table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
									$mergeSize = $xml->getAttribute('table:number-columns-repeated');
									$currCells += $mergeSize;
									$xml->read();
								}
							} while ($xml->name != 'table:table-row');
						}
					} while ($xml->name != 'table:table');

					$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
					$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
					$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
					$worksheetInfo[] = $tmpInfo;
				}
			}

//				foreach($workbookData->table as $worksheetDataSet) {
//					$worksheetData = $worksheetDataSet->children($namespacesContent['table']);
//					$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
//
//					$rowIndex = 0;
//					foreach ($worksheetData as $key => $rowData) {
//						switch ($key) {
//							case 'table-row' :
//								$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
//								$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
//										$rowDataTableAttributes['number-rows-repeated'] : 1;
//								$columnIndex = 0;
//
//								foreach ($rowData as $key => $cellData) {
//									$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
//									$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
//										$cellDataTableAttributes['number-columns-repeated'] : 1;
//									$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
//									if (isset($cellDataOfficeAttributes['value-type'])) {
//										$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1);
//										$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats);
//									}
//									$columnIndex += $colRepeats;
//								}
//								$rowIndex += $rowRepeats;
//								break;
//						}
//					}
//
//					$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
//					$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
//
//				}
//			}
		}

		return $worksheetInfo;
	}
438959
public function fetch($file)
    {
        $templateFile = $this->findTemplateFile($file);

        if (empty($templateFile)) {
            throw new Exception("Template file does not exists: $file");            
        }

        extract($this->vars);
        ob_start();
        include $templateFile;
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
    }
24315
protected function _read($file) {
		$text = file_get_contents($file);
		if (empty($text)) {
			return [];
		}
		$pieces = explode(NL, $text);
		return $pieces;
	}
324169
public function readCell($column, $row, $worksheetName = '') {
    
    return ($row >= $this->firstRow && $row <= $this->lastRow &&
            array_key_exists($column, $this->range));
  }
1164069
public function executeGetOnlyRecords($sheetData = [], $index = [])
	{
		foreach ($sheetData as $key => $data)
		{
			if (!in_array($key, $index))
			{
				unset($sheetData[$key]);
			}
		}
		return $sheetData;
	}
170338
public function read( $offset = NULL, $limit = NULL )
	{
		return $this->load( $this->fileName, $offset, $limit );
	}
633853
@Override
	public Excel03SaxReader read(File file, int sheetIndex) throws POIException {
		try {
			return read(new POIFSFileSystem(file), sheetIndex);
		} catch (IOException e) {
			throw new POIException(e);
		}
	}
459702
protected function loadFile($file)
    {
        if (!stream_is_local($file)) {
            throw new \InvalidArgumentException(sprintf('Procedure file is not a local file: "%s"', $file));
        }

        if (!file_exists($file)) {
            throw new NotExistsException(sprintf('Procedure file does not exist: "%s"', $file));
        }

        return file_get_contents($file);
    }
221911
public static function createSheet(
        \Google_Service_Sheets $googleServiceSheets,
        string $file,
        string $sheet = ClientInterface::DEFAULT_SHEET
    ): SheetInterface {
        return new GoogleSheet($googleServiceSheets, $file, $sheet);
    }
1272819
public static function arrayToXLS(Array $data, String $file = 'excel.xls')
    {
        $file = Base::suffix($file, '.xls');

        header("Content-Disposition: attachment; filename=\"$file\"");
        header("Content-Type: application/vnd.ms-excel;");
        header("Pragma: no-cache");
        header("Expires: 0");

        $output = fopen("php://output", 'w');

        foreach( $data as $column )
        {
            fputcsv($output, $column, "\t");
        }

        fclose($output);
    }
607335
public static function parseFile($file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            $message = "crontab config file is not exists or not readable";
            throw new \RuntimeException($message);
        }

        $tasks = array();
        $lines = file($file);
        foreach ($lines as $line) {
            $job = new JobParse($line);
            $tasks[] = $job->getTask();
        }

        return $tasks;
    }
649375
public function parseFile($file)
    {
        $handle = @fopen($file, 'r');
        if (!$handle) {
            throw new ErrorException(sprintf('Unable to open %s', $file));
        }
        try {
            $this->reset();
            while (!feof($handle)) {
                $buffer = fread($handle, 128);
                $this->parse($buffer);
            }
            $this->throwExceptionIfReadingEntry("\0");
        } finally {
            fclose($handle);
        }
    }
369502
private function importSheet(SheetInterface $sheet, callable $callback = null)
    {
        $headers = [];
        $collection = [];
        $count_header = 0;

        if ($this->with_header) {
            foreach ($sheet->getRowIterator() as $k => $row) {
                if ($k == 1) {
                    $headers = $this->toStrings($row);
                    $count_header = count($headers);
                    continue;
                }
                if ($count_header > $count_row = count($row)) {
                    $row = array_merge($row, array_fill(0, $count_header - $count_row, null));
                } elseif ($count_header < $count_row = count($row)) {
                    $row = array_slice($row, 0, $count_header);
                }
                if ($callback) {
                    if ($result = $callback(array_combine($headers, $row))) {
                        $collection[] = $result;
                    }
                } else {
                    $collection[] = array_combine($headers, $row);
                }
            }
        } else {
            foreach ($sheet->getRowIterator() as $row) {
                $collection[] = $row;
            }
        }

        return $collection;
    }
118733
public static function read($file, $force = false) {
        if (!is_readable($file)) {
            if ($force === true) {
                return [];
            } else {
                throw new Exception(sprintf(
                    'Unable to read file "%s"',
                    $file
                ), ExitApp::RUNTIME_ERROR);
            }
        }

        $fileContent = file_get_contents($file);

        if ($fileContent === false) {
            throw new Exception(sprintf(
                'Unable to read file "%s"',
                $file
            ), ExitApp::RUNTIME_ERROR);
        }

        $result = json_decode(
            trim($fileContent),
            true
        );

        if ($result === false) {
            throw new Exception(sprintf(
                'File "%s" contains invalid JSON data.',
                ExitApp::RUNTIME_ERROR
            ));
        }

        return $result;
    }
1075189
public function fetchAll($limit = null, $offset = null){
		$limit = $limit === null ? -1 : (int) $limit;
		if($offset !== null)
			$this->seek((int) $offset);

		$row = $this->fetch();
		if(!$row)
			return array();

		$rows = array();
		do{
			if($limit === 0)
				break;
			$rows[] = $row;
			$limit--;
		} while($row = $this->fetch());

		return $rows;
	}
1348150
public function getCellsList($offset, $count)
    {
        //check whether workshett name is set or not
        if ($this->worksheetName == '')
            throw new Exception('Worksheet name not specified');
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
            '/worksheets/' . $this->worksheetName . '/cells?offset=' .
            $offset . '&count=' . $count;
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        $listCells = array();
        foreach ($json->Cells->CellList as $cell) {
            $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
                '/worksheets/' . $this->worksheetName . '/cells' . $cell->link->Href;
            $signedURI = Utils::sign($strURI);
            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
            $json = json_decode($responseStream);
            array_push($listCells, $json->Cell);
        }
        return $listCells;

    }