375 $this->autoFilter =
new AutoFilter(null, $this);
384 if ($this->cellCollection !== null) {
385 $this->cellCollection->unsetWorksheetCells();
387 $this->cellCollection = null;
402 $this->rowDimensions = [];
422 return self::$invalidCharacters;
435 if ($CharCount == 0) {
436 throw new Exception(
'Sheet code name cannot be empty.');
440 (str_replace(self::$invalidCharacters,
'', $pValue) !== $pValue) ||
444 throw new Exception(
'Invalid character found in sheet code name');
448 if ($CharCount > self::SHEET_TITLE_MAXIMUM_LENGTH) {
449 throw new Exception(
'Maximum ' . self::SHEET_TITLE_MAXIMUM_LENGTH .
' characters allowed in sheet code name.');
465 if (str_replace(self::$invalidCharacters,
'', $pValue) !== $pValue) {
466 throw new Exception(
'Invalid character found in sheet title');
471 throw new Exception(
'Maximum ' . self::SHEET_TITLE_MAXIMUM_LENGTH .
' characters allowed in sheet title.');
486 if ($this->cellCollection == null) {
491 return $this->cellCollection->getSortedCoordinates();
494 return $this->cellCollection->getCoordinates();
567 if ($iChartIndex === null) {
568 $this->chartCollection[] = $pChart;
571 array_splice($this->chartCollection, $iChartIndex, 0, [$pChart]);
584 return count($this->chartCollection);
596 $chartCount = count($this->chartCollection);
597 if ($chartCount == 0) {
603 if (!isset($this->chartCollection[
$index])) {
607 return $this->chartCollection[
$index];
618 foreach ($this->chartCollection as $chart) {
619 $chartNames[] = $chart->getName();
634 $chartCount = count($this->chartCollection);
635 if ($chartCount == 0) {
638 foreach ($this->chartCollection as
$index => $chart) {
639 if ($chart->getName() == $chartName) {
640 return $this->chartCollection[
$index];
655 $newColumnDimensions = [];
657 foreach ($currentColumnDimensions as $objColumnDimension) {
658 $newColumnDimensions[$objColumnDimension->getColumnIndex()] = $objColumnDimension;
661 $this->columnDimensions = $newColumnDimensions;
674 $newRowDimensions = [];
676 foreach ($currentRowDimensions as $objRowDimension) {
677 $newRowDimensions[$objRowDimension->getRowIndex()] = $objRowDimension;
680 $this->rowDimensions = $newRowDimensions;
717 if ($colDimension->getAutoSize()) {
718 $autoSizes[$colDimension->getColumnIndex()] = -1;
723 if (!empty($autoSizes)) {
728 $isMergeCell[$cellReference] =
true;
735 if ($cell !== null && isset($autoSizes[$this->cellCollection->getCurrentColumn()])) {
737 $isMerged = isset($isMergeCell[$this->cellCollection->getCurrentCoordinate()]);
740 $isMergedButProceed =
false;
743 if ($isMerged && $cell->isMergeRangeValueCell()) {
744 $range = $cell->getMergeRange();
746 if ($rangeBoundaries[0] == 1) {
747 $isMergedButProceed =
true;
752 if (!$isMerged || $isMergedButProceed) {
756 $cell->getCalculatedValue(),
757 $this->
getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode()
760 $autoSizes[$this->cellCollection->getCurrentColumn()] = max(
761 (
float) $autoSizes[$this->cellCollection->getCurrentColumn()],
763 $this->
getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
765 $this->
getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
766 $this->
getParent()->getDefaultStyle()->getFont()
774 foreach ($autoSizes as $columnIndex => $width) {
802 if ($this->
parent !== null) {
803 $definedNames = $this->
parent->getDefinedNames();
804 foreach ($definedNames as $definedName) {
808 $this->
parent->removeSheetByIndex(
809 $this->
parent->getIndex($this)
841 public function setTitle(
$title, $updateFormulaCellReferences =
true, $validate =
true)
853 self::checkSheetTitle(
$title);
870 } elseif (
$i == 100) {
886 if ($this->
parent && $this->
parent->getCalculationEngine()) {
889 $this->
parent->getCalculationEngine()
890 ->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
891 if ($updateFormulaCellReferences) {
918 $this->sheetState = $value;
940 $this->pageSetup = $pValue;
962 $this->pageMargins = $pValue;
984 $this->headerFooter = $pValue;
1006 $this->sheetView = $pValue;
1028 $this->protection = $pValue;
1029 $this->dirty =
true;
1061 return $this->cellCollection->getHighestColumn(
$row);
1074 if ($column == null) {
1091 return $this->cellCollection->getHighestRow($column);
1101 return $this->cellCollection->getHighestRowAndColumn();
1114 $this->getCell($pCoordinate)->setValue($pValue);
1130 $this->getCellByColumnAndRow($columnIndex,
$row)->setValue($value);
1147 $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
1164 $this->getCellByColumnAndRow($columnIndex,
$row)->setValueExplicit($value, $dataType);
1176 public function getCell(
string $coordinate):
Cell 1179 if ($this->cellCollection->has($coordinate)) {
1181 $cell = $this->cellCollection->get($coordinate);
1188 $cell = $sheet->cellCollection->get($finalCoordinate);
1190 return $cell ?? $sheet->createNewCell($finalCoordinate);
1202 $finalCoordinate = null;
1205 if (strpos($pCoordinate,
'!') !==
false) {
1206 $worksheetReference = self::extractSheetTitle($pCoordinate,
true);
1208 $sheet = $this->
parent->getSheetByName($worksheetReference[0]);
1209 $finalCoordinate = strtoupper($worksheetReference[1]);
1212 throw new Exception(
'Sheet not found for name: ' . $worksheetReference[0]);
1220 if ($namedRange !== null) {
1221 $sheet = $namedRange->getWorksheet();
1223 throw new Exception(
'Sheet not found for named range: ' . $namedRange->getName());
1226 $cellCoordinate = ltrim(substr($namedRange->getValue(), strrpos($namedRange->getValue(),
'!')),
'!');
1227 $finalCoordinate = str_replace(
'$',
'', $cellCoordinate);
1231 if (!$sheet || !$finalCoordinate) {
1233 $finalCoordinate = strtoupper($pCoordinate);
1237 throw new Exception(
'Cell coordinate string can not be a range of cells.');
1238 } elseif (strpos($finalCoordinate,
'$') !==
false) {
1239 throw new Exception(
'Cell coordinate must not be absolute.');
1242 return [$sheet, $finalCoordinate];
1255 if ($this->cellCollection->has($coordinate)) {
1256 return $this->cellCollection->get($coordinate);
1270 public function getCellByColumnAndRow($columnIndex,
$row):
Cell 1273 $coordinate = $columnLetter .
$row;
1275 if ($this->cellCollection->has($coordinate)) {
1277 $cell = $this->cellCollection->get($coordinate);
1296 $this->cellCollection->add($pCoordinate, $cell);
1297 $this->cellCollectionIsSorted =
false;
1302 if ($this->cachedHighestColumn < $aIndexes[0]) {
1303 $this->cachedHighestColumn = $aIndexes[0];
1305 if ($aIndexes[1] > $this->cachedHighestRow) {
1306 $this->cachedHighestRow = $aIndexes[1];
1311 $rowDimension = $this->rowDimensions[
$row] ?? null;
1312 $columnDimension = $this->columnDimensions[$column] ?? null;
1314 if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
1316 $cell->setXfIndex($rowDimension->getXfIndex());
1317 } elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
1319 $cell->setXfIndex($columnDimension->getXfIndex());
1332 public function cellExists($coordinate)
1337 return $sheet->cellCollection->has($finalCoordinate);
1361 if (!isset($this->rowDimensions[$pRow])) {
1364 $this->cachedHighestRow = max($this->cachedHighestRow, $pRow);
1367 return $this->rowDimensions[$pRow];
1378 $pColumn = strtoupper($pColumn);
1381 if (!isset($this->columnDimensions[$pColumn])) {
1385 if ($this->cachedHighestColumn < $columnIndex) {
1386 $this->cachedHighestColumn = $columnIndex;
1390 return $this->columnDimensions[$pColumn];
1423 $this->
parent->setActiveSheetIndex($this->
parent->getIndex($this));
1428 return $this->
parent->getCellXfSupervisor();
1440 $pCoordinate = strtoupper($pCoordinate);
1441 if (!isset($this->conditionalStylesCollection[$pCoordinate])) {
1442 $this->conditionalStylesCollection[$pCoordinate] = [];
1445 return $this->conditionalStylesCollection[$pCoordinate];
1457 return isset($this->conditionalStylesCollection[strtoupper($pCoordinate)]);
1469 unset($this->conditionalStylesCollection[strtoupper($pCoordinate)]);
1494 $this->conditionalStylesCollection[strtoupper($pCoordinate)] = $pValue;
1511 if ($columnIndex2 !== null && $row2 !== null) {
1514 return $this->
getStyle($cellRange);
1534 if ($existingStyle = $this->
parent->getCellXfByHashCode($pCellStyle->
getHashCode())) {
1536 $xfIndex = $existingStyle->getIndex();
1539 $workbook->addCellXf($pCellStyle);
1540 $xfIndex = $pCellStyle->
getIndex();
1547 if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
1549 $rangeStart = $rangeEnd;
1554 for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
1555 for (
$row = $rangeStart[1];
$row <= $rangeEnd[1]; ++
$row) {
1575 foreach ($pCellStyle as $cellStyle) {
1577 throw new Exception(
'Style is not a conditional style');
1585 if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
1587 $rangeStart = $rangeEnd;
1592 for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
1593 for (
$row = $rangeStart[1];
$row <= $rangeEnd[1]; ++
$row) {
1612 $pCoordinate = strtoupper($pCoordinate);
1614 if ($pCoordinate !=
'') {
1615 if ($pBreak == self::BREAK_NONE) {
1616 if (isset($this->breaks[$pCoordinate])) {
1617 unset($this->breaks[$pCoordinate]);
1620 $this->breaks[$pCoordinate] = $pBreak;
1623 throw new Exception(
'No cell coordinate specified.');
1663 $pRange = strtoupper($pRange);
1665 if (strpos($pRange,
':') !==
false) {
1674 $upperLeft = $aReferences[0];
1675 if (!$this->cellExists($upperLeft)) {
1680 $count = count($aReferences);
1681 for (
$i = 1;
$i < $count; ++
$i) {
1682 if ($this->cellExists($aReferences[
$i])) {
1687 throw new Exception(
'Merge must be set on a range of cells.');
1720 $pRange = strtoupper($pRange);
1722 if (strpos($pRange,
':') !==
false) {
1726 throw new Exception(
'Cell range ' . $pRange .
' not known as merged.');
1729 throw new Exception(
'Merge can only be removed from a range of cells.');
1789 $pRange = strtoupper($pRange);
1791 if (!$pAlreadyHashed) {
1794 $this->protectedCells[$pRange] = $pPassword;
1828 $pRange = strtoupper($pRange);
1830 if (isset($this->protectedCells[$pRange])) {
1831 unset($this->protectedCells[$pRange]);
1833 throw new Exception(
'Cell range ' . $pRange .
' not known as protected.');
1886 if (is_string($pValue)) {
1887 $this->autoFilter->setRange($pValue);
1888 } elseif (is_object($pValue) && ($pValue instanceof
AutoFilter)) {
1889 $this->autoFilter = $pValue;
1921 $this->autoFilter->setRange(null);
1953 throw new Exception(
'Freeze pane can not be set on a range of cells.');
2010 if ($pBefore >= 1) {
2012 $objReferenceHelper->insertNewBefore(
'A' . $pBefore, 0, $pNumRows, $this);
2014 throw new Exception(
'Rows can only be inserted before at least row 1.');
2030 if (!is_numeric($pBefore)) {
2032 $objReferenceHelper->insertNewBefore($pBefore .
'1', $pNumCols, 0, $this);
2034 throw new Exception(
'Column references should not be numeric.');
2050 if ($beforeColumnIndex >= 1) {
2054 throw new Exception(
'Columns can only be inserted before at least column A (1).');
2068 throw new Exception(
'Rows to be deleted should at least start from row 1.');
2072 $removedRowsCounter = 0;
2074 for (
$r = 0;
$r < $pNumRows; ++
$r) {
2075 if ($pRow +
$r <= $highestRow) {
2077 ++$removedRowsCounter;
2082 $objReferenceHelper->insertNewBefore(
'A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
2083 for (
$r = 0;
$r < $removedRowsCounter; ++
$r) {
2101 if (is_numeric($pColumn)) {
2102 throw new Exception(
'Column references should not be numeric.');
2109 if ($pColumnIndex > $highestColumnIndex) {
2115 $objReferenceHelper->insertNewBefore($pColumn .
'1', -$pNumCols, 0, $this);
2117 $maxPossibleColumnsToBeRemoved = $highestColumnIndex - $pColumnIndex + 1;
2119 for (
$c = 0,
$n = min($maxPossibleColumnsToBeRemoved, $pNumCols);
$c <
$n; ++
$c) {
2139 if ($columnIndex >= 1) {
2143 throw new Exception(
'Columns to be deleted should at least start from column A (1)');
2165 $this->showGridlines = $pValue;
2189 $this->printGridlines = $pValue;
2213 $this->showRowColHeaders = $pValue;
2237 $this->showSummaryBelow = $pValue;
2261 $this->showSummaryRight = $pValue;
2285 $this->comments = $pValue;
2300 $pCellCoordinate = strtoupper($pCellCoordinate);
2303 throw new Exception(
'Cell coordinate string can not be a range of cells.');
2304 } elseif (strpos($pCellCoordinate,
'$') !==
false) {
2305 throw new Exception(
'Cell coordinate string must not be absolute.');
2306 } elseif ($pCellCoordinate ==
'') {
2307 throw new Exception(
'Cell coordinate can not be zero-length string.');
2311 if (isset($this->comments[$pCellCoordinate])) {
2312 return $this->comments[$pCellCoordinate];
2317 $this->comments[$pCellCoordinate] = $newComment;
2377 $pCoordinate = strtoupper($pCoordinate);
2380 $pCoordinate = preg_replace(
'/^([A-Z]+)$/',
'${1}:${1}', $pCoordinate);
2383 $pCoordinate = preg_replace(
'/^(\d+)$/',
'${1}:${1}', $pCoordinate);
2386 $pCoordinate = preg_replace(
'/^([A-Z]+):([A-Z]+)$/',
'${1}1:${2}1048576', $pCoordinate);
2389 $pCoordinate = preg_replace(
'/^(\d+):(\d+)$/',
'A${1}:XFD${2}', $pCoordinate);
2393 $this->activeCell = $first[0];
2395 $this->activeCell = $pCoordinate;
2397 $this->selectedCells = $pCoordinate;
2434 $this->rightToLeft = $value;
2449 public function fromArray(array
$source, $nullValue = null, $startCell =
'A1', $strictNullComparison =
false)
2452 if (!is_array(end($source))) {
2460 foreach ($source as $rowData) {
2461 $currentColumn = $startColumn;
2462 foreach ($rowData as $cellValue) {
2463 if ($strictNullComparison) {
2464 if ($cellValue !== $nullValue) {
2466 $this->getCell($currentColumn . $startRow)->setValue($cellValue);
2469 if ($cellValue != $nullValue) {
2471 $this->getCell($currentColumn . $startRow)->setValue($cellValue);
2494 public function rangeToArray($pRange, $nullValue = null, $calculateFormulas =
true, $formatData =
true, $returnCellRef =
false)
2501 $minRow = $rangeStart[1];
2503 $maxRow = $rangeEnd[1];
2509 $rRef = $returnCellRef ?
$row : ++
$r;
2512 for ($col = $minCol; $col != $maxCol; ++$col) {
2513 $cRef = $returnCellRef ? $col : ++
$c;
2516 if ($this->cellCollection->has($col .
$row)) {
2518 $cell = $this->cellCollection->get($col .
$row);
2519 if ($cell->getValue() !== null) {
2520 if ($cell->getValue() instanceof
RichText) {
2521 $returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText();
2523 if ($calculateFormulas) {
2524 $returnValue[$rRef][$cRef] = $cell->getCalculatedValue();
2526 $returnValue[$rRef][$cRef] = $cell->getValue();
2531 $style = $this->
parent->getCellXfByIndex($cell->getXfIndex());
2533 $returnValue[$rRef][$cRef],
2539 $returnValue[$rRef][$cRef] = $nullValue;
2543 $returnValue[$rRef][$cRef] = $nullValue;
2549 return $returnValue;
2555 if ($namedRange === null) {
2556 if ($returnNullIfInvalid) {
2560 throw new Exception(
'Named Range ' . $definedName .
' does not exist.');
2563 if ($namedRange->isFormula()) {
2564 if ($returnNullIfInvalid) {
2568 throw new Exception(
'Defined Named ' . $definedName .
' is a formula, not a range or cell.');
2571 if ($namedRange->getLocalOnly() && $this->
getHashCode() !== $namedRange->getWorksheet()->getHashCode()) {
2572 if ($returnNullIfInvalid) {
2577 'Named range ' . $definedName .
' is not accessible from within sheet ' . $this->
getTitle()
2596 public function namedRangeToArray(
string $definedName, $nullValue = null, $calculateFormulas =
true, $formatData =
true, $returnCellRef =
false)
2599 $workSheet = $namedRange->getWorksheet();
2600 $cellRange = ltrim(substr($namedRange->getValue(), strrpos($namedRange->getValue(),
'!')),
'!');
2601 $cellRange = str_replace(
'$',
'', $cellRange);
2603 return $workSheet->rangeToArray($cellRange, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
2617 public function toArray($nullValue = null, $calculateFormulas =
true, $formatData =
true, $returnCellRef =
false)
2627 return $this->
rangeToArray(
'A1:' . $maxCol . $maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
2640 return new RowIterator($this, $startRow, $endRow);
2664 $this->cellCollection->get(
'A1');
2667 $colRow = $this->cellCollection->getHighestRowAndColumn();
2668 $highestRow = $colRow[
'row'];
2672 foreach ($this->columnDimensions as $dimension) {
2677 foreach ($this->rowDimensions as $dimension) {
2678 $highestRow = max($highestRow, $dimension->getRowIndex());
2682 if ($highestColumn < 1) {
2683 $this->cachedHighestColumn = 1;
2685 $this->cachedHighestColumn = $highestColumn;
2687 $this->cachedHighestRow = $highestRow;
2701 $this->
hash = md5($this->title . $this->autoFilter . ($this->protection->isProtectionEnabled() ?
't' :
'f') . __CLASS__);
2702 $this->dirty =
false;
2722 if (($sep = strrpos($pRange,
'!')) ===
false) {
2723 return $returnRange ? [
'', $pRange] :
'';
2727 return [substr($pRange, 0, $sep), substr($pRange, $sep + 1)];
2730 return substr($pRange, $sep + 1);
2743 if (isset($this->hyperlinkCollection[$pCellCoordinate])) {
2744 return $this->hyperlinkCollection[$pCellCoordinate];
2748 $this->hyperlinkCollection[$pCellCoordinate] =
new Hyperlink();
2750 return $this->hyperlinkCollection[$pCellCoordinate];
2762 if ($pHyperlink === null) {
2763 unset($this->hyperlinkCollection[$pCellCoordinate]);
2765 $this->hyperlinkCollection[$pCellCoordinate] = $pHyperlink;
2780 return isset($this->hyperlinkCollection[$pCoordinate]);
2803 if (isset($this->dataValidationCollection[$pCellCoordinate])) {
2804 return $this->dataValidationCollection[$pCellCoordinate];
2808 $this->dataValidationCollection[$pCellCoordinate] =
new DataValidation();
2810 return $this->dataValidationCollection[$pCellCoordinate];
2822 if ($pDataValidation === null) {
2823 unset($this->dataValidationCollection[$pCellCoordinate]);
2825 $this->dataValidationCollection[$pCellCoordinate] = $pDataValidation;
2840 return isset($this->dataValidationCollection[$pCoordinate]);
2866 $rangeBlocks = explode(
' ', $range);
2867 foreach ($rangeBlocks as &$rangeSet) {
2873 if ($rangeBoundaries[0][1] > $maxRow) {
2874 $rangeBoundaries[0][1] = $maxRow;
2879 if ($rangeBoundaries[1][1] > $maxRow) {
2880 $rangeBoundaries[1][1] = $maxRow;
2882 $rangeSet = $rangeBoundaries[0][0] . $rangeBoundaries[0][1] .
':' . $rangeBoundaries[1][0] . $rangeBoundaries[1][1];
2886 return implode(
' ', $rangeBlocks);
2896 if ($this->tabColor === null) {
2897 $this->tabColor =
new Color();
2910 $this->tabColor = null;
2922 return $this->tabColor !== null;
2941 foreach ($this as
$key => $val) {
2942 if (
$key ==
'parent') {
2946 if (is_object($val) || (is_array($val))) {
2947 if (
$key ==
'cellCollection') {
2948 $newCollection = $this->cellCollection->cloneCellCollection($this);
2949 $this->cellCollection = $newCollection;
2950 } elseif (
$key ==
'drawingCollection') {
2953 foreach ($currentCollection as $item) {
2954 if (is_object($item)) {
2955 $newDrawing = clone $item;
2956 $newDrawing->setWorksheet($this);
2959 } elseif ((
$key ==
'autoFilter') && ($this->autoFilter instanceof
AutoFilter)) {
2961 $this->autoFilter = $newAutoFilter;
2962 $this->autoFilter->setParent($this);
2964 $this->{
$key} = unserialize(serialize($val));
2988 $pValue = str_replace(
' ',
'_', $pValue);
2992 self::checkSheetCodeName($pValue);
2998 if ($this->
getParent()->sheetCodeNameExists($pValue)) {
3005 while ($this->
getParent()->sheetCodeNameExists($pValue .
'_' .
$i)) {
3011 } elseif ($i == 100) {
3018 $pValue .=
'_' .
$i;
3023 $this->codeName = $pValue;
3045 return $this->codeName !== null;
static coordinateIsRange($coord)
Checks if a coordinate represents a range of cells.
removeConditionalStyles($pCoordinate)
Removes conditional styles for a cell.
getFreezePane()
Get Freeze Pane.
getHighestRow($column=null)
Get highest worksheet row.
getSelectedCells()
Get selected cells.
refreshRowDimensions()
Refresh row dimensions.
static splitRange($pRange)
Split range into coordinate strings.
getDataValidation($pCellCoordinate)
Get data validation.
setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)
Set Autofilter Range by using numeric cell coordinates.
getChartByName($chartName)
Get a chart by name.
setCellValueByColumnAndRow($columnIndex, $row, $value)
Set a cell value by using numeric cell coordinates.
calculateWorksheetDataDimension()
Calculate worksheet data dimension.
mergeCells($pRange)
Set merge on a cell range.
removeAutoFilter()
Remove autofilter.
setPageMargins(PageMargins $pValue)
Set page margins.
getShowSummaryRight()
Show summary right? (Row/Column outlining).
getMergeCells()
Get merge cells array.
conditionalStylesExists($pCoordinate)
Do conditional styles exist for this cell?
setPageSetup(PageSetup $pValue)
Set page setup.
getColumnDimensions()
Get collection of column dimensions.
static extractSheetTitle($pRange, $returnRange=false)
Extract worksheet title from range.
getChartNames()
Return an array of the names of charts on this worksheet.
duplicateConditionalStyle(array $pCellStyle, $pRange='')
Duplicate conditional style to a range of cells.
static countCharacters($value, $enc='UTF-8')
Get character count.
getPageMargins()
Get page margins.
getWorksheetAndCoordinate(string $pCoordinate)
Get the correct Worksheet and coordinate from a coordinate that may contains reference to another she...
disconnectCells()
Disconnect all cells from this Worksheet object, typically so that the worksheet object can be unset...
hyperlinkExists($pCoordinate)
Hyperlink at a specific coordinate exists?
setComments(array $pValue)
Set comments array for the entire sheet.
setShowGridlines($pValue)
Set show gridlines.
getPrintGridlines()
Print gridlines?
static hashPassword(string $password, string $algorithm='', string $salt='', int $spinCount=10000)
Create a password hash from a given string by a specific algorithm.
getCodeName()
Return the code name of the sheet.
getPageSetup()
Get page setup.
getHashCode()
Get hash code.
removeColumnByIndex($columnIndex, $numColumns=1)
Remove a column, updating all possible related data.
cellExistsByColumnAndRow($columnIndex, $row)
Cell at a specific coordinate by using numeric cell coordinates exists?
getCellOrNull($coordinate)
Get an existing cell at a specific coordinate, or null.
insertNewRowBefore($pBefore, $pNumRows=1)
Insert a new row, updating all possible related data.
setHyperlink($pCellCoordinate, ?Hyperlink $pHyperlink=null)
Set hyperlink.
getRowIterator($startRow=1, $endRow=null)
Get row iterator.
getDefaultColumnDimension()
Get default column dimension.
setConditionalStyles($pCoordinate, $pValue)
Set conditional styles.
__destruct()
Code to execute when this worksheet is unset().
isTabColorSet()
Tab color set?
createNewCell($pCoordinate)
Create a new cell at the specified coordinate.
getCoordinates($sorted=true)
Get a sorted list of all cell coordinates currently held in the collection by row and column...
getStyle($pCellCoordinate)
Get style for cell.
setTitle($title, $updateFormulaCellReferences=true, $validate=true)
Set title.
getShowRowColHeaders()
Show row and column headers?
getHighestDataRow($column=null)
Get highest worksheet row that contains data.
setCellValue($pCoordinate, $pValue)
Set a cell value.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
getProtectedCells()
Get protected cells.
protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $password, $alreadyHashed=false)
Set protection on a cell range by using numeric cell coordinates.
unmergeCells($pRange)
Remove merge on a cell range.
getTopLeftCell()
Get the default position of the right bottom pane.
getRowDimensions()
Get collection of row dimensions.
getColumnIterator($startColumn='A', $endColumn=null)
Get column iterator.
getIndex()
Get own index in style collection.
$conditionalStylesCollection
dataValidationExists($pCoordinate)
Data validation at a specific coordinate exists?
setSelectedCell($pCoordinate)
Selected cell.
setWorksheet(?Worksheet $pValue=null)
Set Worksheet.
getComments()
Get comments.
setRightToLeft($value)
Set right-to-left.
mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)
Set merge on a cell range by using numeric cell coordinates.
calculateColumnWidths()
Calculate widths for auto-size columns.
getHyperlink($pCellCoordinate)
Get hyperlink.
protectCells($pRange, $pPassword, $pAlreadyHashed=false)
Set protection on a cell range.
$dataValidationCollection
setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $dataType)
Set a cell value by using numeric cell coordinates.
duplicateStyle(Style $pCellStyle, $pRange)
Duplicate cell style to a range of cells.
removeRow($pRow, $pNumRows=1)
Delete a row, updating all possible related data.
getDataValidationCollection()
Get collection of data validations.
getCommentByColumnAndRow($columnIndex, $row)
Get comment for cell by using numeric cell coordinates.
getDefaultRowDimension()
Get default row dimension.
unfreezePane()
Unfreeze Pane.
getShowSummaryBelow()
Show summary below? (Row/Column outlining).
insertNewColumnBeforeByIndex($beforeColumnIndex, $pNumCols=1)
Insert a new column, updating all possible related data.
static checkSheetCodeName($pValue)
Check sheet code name for valid Excel syntax.
Paper size taken from Office Open XML Part 4 - Markup Language Reference, page 1988:.
unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)
Remove merge on a cell range by using numeric cell coordinates.
rangeToArray($pRange, $nullValue=null, $calculateFormulas=true, $formatData=true, $returnCellRef=false)
Create array from a range of cells.
getRowDimension(int $pRow)
Get row dimension at a specific row.
unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)
Remove protection on a cell range by using numeric cell coordinates.
hasCodeName()
Sheet has a code name ?
static $invalidCharacters
setBreakByColumnAndRow($columnIndex, $row, $break)
Set break on a cell by using numeric cell coordinates.
setPrintGridlines($pValue)
Set print gridlines.
setHeaderFooter(HeaderFooter $pValue)
Set page header/footer.
setAutoFilter($pValue)
Set AutoFilter.
setSheetState($value)
Set sheet state.
static resolveName(string $pDefinedName, Worksheet $pSheet, string $sheetName='')
Resolve a named range to a regular cell range or formula.
const SHEET_TITLE_MAXIMUM_LENGTH
setCodeName($pValue, $validate=true)
Define the code name of the sheet.
getSheetView()
Get sheet view.
calculateWorksheetDimension()
Calculate worksheet dimension.
getChartCount()
Return the count of charts on this worksheet.
freezePaneByColumnAndRow($columnIndex, $row)
Freeze Pane by using numeric cell coordinates.
static getInstance()
Get an instance of this class.
static indexesFromString(string $coordinates)
Get indexes from a string coordinates.
const CALCULATION_REGEXP_CELLREF
getHashCode()
Get hash code.
static checkSheetTitle($pValue)
Check sheet title for valid Excel syntax.
setShowSummaryBelow($pValue)
Set show summary below.
shrinkRangeToFit($range)
Accepts a range, returning it as a range that falls within the current highest row and column of the ...
copy()
Copy worksheet (!= clone!).
static getInstance(Worksheet $parent)
Initialise the cache storage.
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
setMergeCells(array $pValue)
Set merge cells array for the entire sheet.
getChartByIndex($index)
Get a chart by its index position.
removeColumn($pColumn, $pNumCols=1)
Remove a column, updating all possible related data.
getHighestColumn($row=null)
Get highest worksheet column.
__construct(?Spreadsheet $parent=null, $pTitle='Worksheet')
Create a new worksheet.
resetTabColor()
Reset tab color.
setShowRowColHeaders($pValue)
Set show row and column headers.
static getInvalidCharacters()
Get array of invalid characters for sheet title.
setDataValidation($pCellCoordinate, ?DataValidation $pDataValidation=null)
Set data validation.
getProtection()
Get Protection.
freezePane($cell, $topLeftCell=null)
Freeze Pane.
refreshColumnDimensions()
Refresh column dimensions.
rebindParent(Spreadsheet $parent)
Re-bind parent.
static coordinateFromString($pCoordinateString)
Coordinate from string.
unprotectCells($pRange)
Remove protection on a cell range.
addDefinedName(DefinedName $definedName)
Add a defined name (either a named range or a named formula).
getDrawingCollection()
Get collection of drawings.
getHighestRowAndColumn()
Get highest worksheet column and highest row that have cell records.
getColumnDimension(string $pColumn)
Get column dimension at a specific column.
getConditionalStylesCollection()
Get collection of conditional styles.
getHyperlinkCollection()
Get collection of hyperlinks.
getHeaderFooter()
Get page header/footer.
static rangeBoundaries($pRange)
Calculate range boundaries.
static getRangeBoundaries($pRange)
Calculate range boundaries.
static substring($pValue, $pStart, $pLength=0)
Get a substring of a UTF-8 encoded string.
const SHEETSTATE_VERYHIDDEN
static extractAllCellReferencesInRange($cellRange)
Extract all cell references in range, which may be comprised of multiple cell ranges.
setProtection(Protection $pValue)
Set Protection.
setCellValueExplicit($pCoordinate, $pValue, $pDataType)
Set a cell value.
addChart(Chart $pChart, $iChartIndex=null)
Add chart.
setSelectedCellByColumnAndRow($columnIndex, $row)
Selected cell by using numeric cell coordinates.
getCellCollection()
Return the cell collection.
fromArray(array $source, $nullValue=null, $startCell='A1', $strictNullComparison=false)
Fill worksheet from values in array.
setSheetView(SheetView $pValue)
Set sheet view.
namedRangeToArray(string $definedName, $nullValue=null, $calculateFormulas=true, $formatData=true, $returnCellRef=false)
Create array from a range of cells.
getActiveCell()
Get active cell.
setBreak($pCoordinate, $pBreak)
Set break on a cell.
toArray($nullValue=null, $calculateFormulas=true, $formatData=true, $returnCellRef=false)
Create array from worksheet.
getChartCollection()
Get collection of charts.
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
getRightToLeft()
Get right-to-left.
setShowSummaryRight($pValue)
Set show summary right.
validateNamedRange(string $definedName, bool $returnNullIfInvalid=false)
static columnIndexFromString($pString)
Column index from string.
getStyleByColumnAndRow($columnIndex1, $row1, $columnIndex2=null, $row2=null)
Get style for cell by using numeric cell coordinates.
getColumnDimensionByColumn(int $columnIndex)
Get column dimension at a specific column by using numeric cell coordinates.
getComment($pCellCoordinate)
Get comment for cell.
getSheetState()
Get sheet state.
insertNewColumnBefore($pBefore, $pNumCols=1)
Insert a new column, updating all possible related data.
getAutoFilter()
Get Autofilter.
setSelectedCells($pCoordinate)
Select a range of cells.
garbageCollect()
Run PhpSpreadsheet garbage collector.
static stringFromColumnIndex($columnIndex)
String from column index.
getShowGridlines()
Show gridlines?
static rangeDimension($pRange)
Calculate range dimension.
getTabColor()
Get tab color.
const CALCULATION_REGEXP_DEFINEDNAME
static calculateColumnWidth(\PhpOffice\PhpSpreadsheet\Style\Font $font, $cellText='', $rotation=0, ?\PhpOffice\PhpSpreadsheet\Style\Font $defaultFont=null)
Calculate an (approximate) OpenXML column width, based on font size and text contained.
getConditionalStyles($pCoordinate)
Get conditional styles for a cell.
getHighestDataColumn($row=null)
Get highest worksheet column that contains data.