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

@return array

@throws \MercesLab\Component\SpreadsheetClient\Exception\ReadRequestFailedException
196754
public function read(
        string $file,
        string $sheet = self::DEFAULT_SHEET,
        string $range = self::DEFAULT_RANGE,
        int $offset = self::DEFAULT_OFFSET,
        int $limit = self::DEFAULT_LIMIT
    ): array {
        return $this->doRead($file, $sheet, $range, $offset, $limit);
    }
539326
public function clearCellsContents($range)
    {
        if ($range == '')
            throw new Exception('Range not specified');
        
        //Build URI
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . 
                  '/cells/clearcontents?range=' . $range;
        //Sign URI
        $signedURI = Utils::sign($strURI);
        
        //Send request and receive response
        $response = Utils::processCommand($signedURI, 'POST', '', '');
        $json = json_decode($response);
        if ($json->Code == 200)
            return true;
        else
            return false;
    }
12925
public function write(
        array $data,
        string $file,
        string $sheet = self::DEFAULT_SHEET,
        string $range = self::DEFAULT_RANGE
    ): void {
        $this->doWrite($data, $file, $sheet, $range);
    }
1022461
public function listWorksheetInfo($pFilename)
	{
		// Open file
		$this->_openFile($pFilename);
		if (!$this->_isValidFormat()) {
			fclose ($this->_fileHandle);
			throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
		}
		$fileHandle = $this->_fileHandle;
		rewind($fileHandle);

		$worksheetInfo = array();
		$worksheetInfo[0]['worksheetName'] = 'Worksheet';
		$worksheetInfo[0]['lastColumnLetter'] = 'A';
		$worksheetInfo[0]['lastColumnIndex'] = 0;
		$worksheetInfo[0]['totalRows'] = 0;
		$worksheetInfo[0]['totalColumns'] = 0;

		// Loop through file
		$rowData = array();

		// loop through one row (line) at a time in the file
		$rowIndex = 0;
		while (($rowData = fgets($fileHandle)) !== FALSE) {
			$columnIndex = 0;

			// convert SYLK encoded $rowData to UTF-8
			$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);

			// explode each row at semicolons while taking into account that literal semicolon (;)
			// is escaped like this (;;)
			$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));

			$dataType = array_shift($rowData);
			if ($dataType == 'C') {
				//  Read cell value data
				foreach($rowData as $rowDatum) {
					switch($rowDatum{0}) {
						case 'C' :
						case 'X' :
							$columnIndex = substr($rowDatum,1) - 1;
							break;
						case 'R' :
						case 'Y' :
							$rowIndex = substr($rowDatum,1);
							break;
					}

					$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
					$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
				}
			}
		}

		$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
		$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;

		// Close file
		fclose($fileHandle);

		return $worksheetInfo;
	}
250683
public function readSet($offset = 0, $limit = 10, $params = [])
    {
        $select = $this->getTable()::select();

        // select only required fields
        if (\count($this->getFields())) {
            $fields = $this->getFields();
            $name = $this->getTable()->getName();
            $fields = array_map(
                function ($field) use ($name) {
                    return $name .'.'. $field;
                },
                $fields
            );
            $select->select(implode(', ', $fields));
        }

        // switch statement for DB type
        $type = Proxy\Db::getOption('connect', 'type');
        switch ($type) {
            case 'mysql':
                $selectPart = $select->getSelect();
                $selectPart[0] = 'SQL_CALC_FOUND_ROWS ' . $selectPart[0];
                $select->select(...$selectPart);
                $totalSQL = 'SELECT FOUND_ROWS()';
                break;
            case 'pgsql':
            default:
                $selectTotal = clone $select;
                $selectTotal->select('COUNT(*)');
                $totalSQL = $selectTotal->getSql();
                break;
        }

        $select->setLimit($limit);
        $select->setOffset($offset);

        $result = [];
        $total = 0;

        // run queries
        // use transaction to avoid errors
        Proxy\Db::transaction(
            function () use (&$result, &$total, $select, $totalSQL) {
                $result = $select->execute();
                $total = Proxy\Db::fetchOne($totalSQL);
            }
        );

        return [$result, $total];
    }
1339614
static public function
	FromFile($file) {
	/*//
	return Nether\OneScript\Project
	read a project file from disk.
	//*/

		if(!file_exists($file) && is_readable($file))
		throw new Exception(
			'file not found or unreadable',
			static::ErrorFileUnreadable
		);

		$input = json_decode(file_get_contents($file));

		if(!$input || !is_object($input))
		throw new Exception(
			'file appears to be invalid',
			static::ErrorFileInvalid
		);

		$project = (new static($input))
		->SetProjectFile($file);

		return $project;
	}
822561
public function get($limit = 0, $offset = 0)
    {

        //check if there is an error
        if (static::$response['status'] == "error") {
           return static::terminate(static::$response);
        }

        //check if the limit is a number
        if (!is_numeric($limit)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter limit should be numeric at function get()";
            static::$response["code"] = 6000;

            return static::terminate(static::$response);
        }

        //check if the offset is a number
        if (!is_numeric($offset)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter offset should be numeric at function get()";
            static::$response["code"] = 6001;

            return static::terminate(static::$response);
        }

        $table_name = self::$table;

        /* if no column passed as param, select all	 */
        $columns = empty($this->columns) ? "*" : $this->columns;

        $query = /** @lang text */
            "SELECT {$columns} FROM {$table_name}";

        if (!empty($this->whereby)) {

            $query = $query . ' WHERE ' . $this->whereby;
        }
        if(!empty($this->groupby)){
            $query.=' GROUP BY '.$this->groupby;
        }

        if (!empty($this->order)) {
            $query .= $this->order;
        }


        if (!empty($limit)) {
            $query = $query . ' LIMIT ' . $limit;
        }
        if (!empty($offset)) {
            $query = $query . ' OFFSET ' . $offset;
        }



          return  $this->fetch($query);
    }
315164
function &read($file) {
		if (!$this->dir || !is_file($dst=$this->dir.$file)) {
			if (!isset($this->data[$file]))
				$this->data[$file]=[];
			return $this->data[$file];
		}
		if ($this->lazy && isset($this->data[$file]))
			return $this->data[$file];
		$fw=\Base::instance();
		$raw=$fw->read($dst);
		switch ($this->format) {
			case self::FORMAT_JSON:
				$data=json_decode($raw,TRUE);
				break;
			case self::FORMAT_Serialized:
				$data=$fw->unserialize($raw);
				break;
		}
		$this->data[$file] = $data;
		return $this->data[$file];
	}
468490
public function getMaxColumn($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);
        return $json->Cells->MaxColumn;

    }
903942
function readFile($file)
	{
		$fh = @fopen($file, 'r');

		$lines = false;
		if ($fh !== false) {
			$lines = array();
			while (!feof($fh)) {
				$lines[] = fgets($fh);
			}
			fclose($fh);
		}
		return $lines;
	}
337962
public function getLists($offset = 0, $limit = 100)
	{
		$lists = [];
		foreach ($this->client->get("lists?offset={$offset}&limit={$limit}") as $list) {
			$lists[] = new Resources\MailingList($this, $list);
		}
		return $lists;
	}
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);
        }
    }
1344147
private static function loadDefinitionsFromFile(string $file): array
    {
        if (!\is_file($file) || !\is_readable($file)) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(\sprintf('"%s" must be a readable file', $file));
            // @codeCoverageIgnoreEnd
        }

        $definitions = require $file;

        if (!\is_array($definitions)) {
            throw new \RuntimeException(
                \sprintf('Definitions file should return an array. "%s" returned', \gettype($definitions))
            );
        }

        return $definitions;
    }
1056476
public function read(
        string $sheet = ClientInterface::DEFAULT_SHEET,
        string $range = ClientInterface::DEFAULT_RANGE,
        int $offset = ClientInterface::DEFAULT_OFFSET,
        int $limit = ClientInterface::DEFAULT_LIMIT
    ): array {
        return $this->doRead($this->file, $sheet, $range, $offset, $limit);
    }
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;
	}
324169
public function readCell($column, $row, $worksheetName = '') {
    
    return ($row >= $this->firstRow && $row <= $this->lastRow &&
            array_key_exists($column, $this->range));
  }
1369899
public function validateFile($file)
    {
        if (file_exists($file) !== true) {
            throw new Exception('File not found');
        }
        if (is_readable($file) !== true) {
            throw new Exception('File not readable');
        }

        $data = file_get_contents($file);
        if ($data === false) {
            throw new Exception('Failed get file');
        }

        return $this->validateFragment($data);
    }