diff --git a/src/Spout/Reader/ODS/SheetIterator.php b/src/Spout/Reader/ODS/SheetIterator.php index c23f844..4a311d4 100644 --- a/src/Spout/Reader/ODS/SheetIterator.php +++ b/src/Spout/Reader/ODS/SheetIterator.php @@ -116,7 +116,7 @@ class SheetIterator implements IteratorInterface $escapedSheetName = $this->xmlReader->getAttribute(self::XML_ATTRIBUTE_TABLE_NAME); $sheetName = $this->escaper->unescape($escapedSheetName); - return new Sheet($this->xmlReader, $sheetName, $this->currentSheetIndex, $this->options); + return new Sheet($this->xmlReader, $this->currentSheetIndex, $sheetName, $this->options); } /** diff --git a/tests/Spout/Reader/ODS/SheetTest.php b/tests/Spout/Reader/ODS/SheetTest.php new file mode 100644 index 0000000..1c98347 --- /dev/null +++ b/tests/Spout/Reader/ODS/SheetTest.php @@ -0,0 +1,51 @@ +openFileAndReturnSheets('two_sheets_with_custom_names.ods'); + + $this->assertEquals('Sheet First', $sheets[0]->getName()); + $this->assertEquals(0, $sheets[0]->getIndex()); + + $this->assertEquals('Sheet Last', $sheets[1]->getName()); + $this->assertEquals(1, $sheets[1]->getIndex()); + } + + /** + * @param string $fileName + * @return Sheet[] + */ + private function openFileAndReturnSheets($fileName) + { + $resourcePath = $this->getResourcePath($fileName); + $reader = ReaderFactory::create(Type::ODS); + $reader->open($resourcePath); + + $sheets = []; + foreach ($reader->getSheetIterator() as $sheet) { + $sheets[] = $sheet; + } + + $reader->close(); + + return $sheets; + } +} diff --git a/tests/resources/ods/two_sheets_with_custom_names.ods b/tests/resources/ods/two_sheets_with_custom_names.ods new file mode 100644 index 0000000..933a94c Binary files /dev/null and b/tests/resources/ods/two_sheets_with_custom_names.ods differ