43 public static function OFFSET($cellAddress = null,
$rows = 0,
$columns = 0, $height = null, $width = null, ?
Cell $pCell = null)
50 if ($cellAddress === null || $cellAddress ===
'') {
54 if (!is_object($pCell)) {
58 [$cellAddress, $pSheet] = self::extractWorksheet($cellAddress, $pCell);
60 $startCell = $endCell = $cellAddress;
61 if (strpos($cellAddress,
':')) {
62 [$startCell, $endCell] = explode(
':', $cellAddress);
67 $startCellRow +=
$rows;
71 if (($startCellRow <= 0) || ($startCellColumn < 0)) {
75 $endCellColumn = self::adjustEndCellColumnForWidth($endCellColumn, $width, $startCellColumn,
$columns);
78 $endCellRow = self::adustEndCellRowForHeight($height, $startCellRow,
$rows, $endCellRow);
80 if (($endCellRow <= 0) || ($endCellColumn < 0)) {
85 $cellAddress =
"{$startCellColumn}{$startCellRow}";
86 if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) {
87 $cellAddress .=
":{$endCellColumn}{$endCellRow}";
90 return self::extractRequiredCells($pSheet, $cellAddress);
102 if (strpos($cellAddress,
'!') !==
false) {
104 $sheetName = trim($sheetName,
"'");
107 $pSheet = ($sheetName !==
'')
108 ? $pCell->
getWorksheet()->getParent()->getSheetByName($sheetName)
111 return [$cellAddress, $pSheet];
117 if (($width !== null) && (!is_object($width))) {
118 $endCellColumn = $startCellColumn + (int) $width - 1;
123 return $endCellColumn;
128 if (($height !== null) && (!is_object($height))) {
129 $endCellRow = $startCellRow + (int) $height - 1;
131 $endCellRow += (int)
$rows;
static extractRequiredCells(?Worksheet $pSheet, string $cellAddress)
static extractSheetTitle($pRange, $returnRange=false)
Extract worksheet title from range.
static OFFSET($cellAddress=null, $rows=0, $columns=0, $height=null, $width=null, ?Cell $pCell=null)
OFFSET.
static adjustEndCellColumnForWidth(string $endCellColumn, $width, int $startCellColumn, $columns)
static adustEndCellRowForHeight($height, int $startCellRow, $rows, $endCellRow)
extractCellRange(&$pRange='A1', ?Worksheet $pSheet=null, $resetLog=true)
Extract range values.
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
static coordinateFromString($pCoordinateString)
Coordinate from string.
static extractWorksheet($cellAddress, Cell $pCell)
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static columnIndexFromString($pString)
Column index from string.
static stringFromColumnIndex($columnIndex)
String from column index.
getWorksheet()
Get parent worksheet.