Skip to content

Commit ca284fa

Browse files
authored
Update Spreadsheet.php
1 parent f52d709 commit ca284fa

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/PhpSpreadsheet/Spreadsheet.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,10 @@ public function getAllSheets(): array
660660
*/
661661
public function getSheetByName(string $worksheetName): ?Worksheet
662662
{
663-
$worksheetCount = count($this->workSheetCollection);
664663
$trimWorksheetName = trim($worksheetName, "'");
665-
666-
for ($i = 0; $i < $worksheetCount; ++$i) {
667-
if (strcasecmp($this->workSheetCollection[$i]->getTitle(), $trimWorksheetName) === 0) {
668-
return $this->workSheetCollection[$i];
664+
foreach ($this->workSheetCollection as $worksheet) {
665+
if (strcasecmp($worksheet->getTitle(), $trimWorksheetName) === 0) {
666+
return $worksheet;
669667
}
670668
}
671669

0 commit comments

Comments
 (0)