private function PHPExcel_Reader_Excel5::_readSheetRangeByRefIndex in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_readSheetRangeByRefIndex()
* Get a sheet range like Sheet1:Sheet3 from REF index * Note: If there is only one sheet in the range, one gets e.g Sheet1 * It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets, * in which case an PHPExcel_Reader_Exception is thrown * *
Parameters
int $index: * @return string|false * @throws PHPExcel_Reader_Exception
1 call to PHPExcel_Reader_Excel5::_readSheetRangeByRefIndex()
- PHPExcel_Reader_Excel5::_getNextToken in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel5.php - * Fetch next token from binary formula data * *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel5.php, line 6359
Class
- PHPExcel_Reader_Excel5
- PHPExcel_Reader_Excel5
Code
private function _readSheetRangeByRefIndex($index) {
if (isset($this->_ref[$index])) {
$type = $this->_externalBooks[$this->_ref[$index]['externalBookIndex']]['type'];
switch ($type) {
case 'internal':
// check if we have a deleted 3d reference
if ($this->_ref[$index]['firstSheetIndex'] == 0xffff or $this->_ref[$index]['lastSheetIndex'] == 0xffff) {
throw new PHPExcel_Reader_Exception('Deleted sheet reference');
}
// we have normal sheet range (collapsed or uncollapsed)
$firstSheetName = $this->_sheets[$this->_ref[$index]['firstSheetIndex']]['name'];
$lastSheetName = $this->_sheets[$this->_ref[$index]['lastSheetIndex']]['name'];
if ($firstSheetName == $lastSheetName) {
// collapsed sheet range
$sheetRange = $firstSheetName;
}
else {
$sheetRange = "{$firstSheetName}:{$lastSheetName}";
}
// escape the single-quotes
$sheetRange = str_replace("'", "''", $sheetRange);
// if there are special characters, we need to enclose the range in single-quotes
// todo: check if we have identified the whole set of special characters
// it seems that the following characters are not accepted for sheet names
// and we may assume that they are not present: []*/:\?
if (preg_match("/[ !\"@#£\$%&{()}<>=+'|^,;-]/", $sheetRange)) {
$sheetRange = "'{$sheetRange}'";
}
return $sheetRange;
break;
default:
// TODO: external sheet support
throw new PHPExcel_Reader_Exception('Excel5 reader only supports internal sheets in fomulas');
break;
}
}
return false;
}