diff --git a/README.md b/README.md index 90fc4bc..164e6fe 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,11 @@ Jump to: * [Cell value types](#cell-value-types) * [How to get complete info about the cell style](#how-to-get-complete-info-about-the-cell-style) * [Retrieve data validation rules](#retrieve-data-validation-rules) +* [Column Widths](#column-widths) +* [Row Heights](#row-heights) +* [Freeze Pane Info](#freeze-pane-info) +* [Tab Color Info](#tab-color-info) +* [Info about merged cells](#info-about-merged-cells) * [Some useful methods](#some-useful-methods) ## Usage @@ -528,7 +533,7 @@ Array ) ``` -## How to get complete info about the cell style +## How to get complete info about the cell style Usually read functions return just cell values, but you can read the values with styles. In this case, for each cell, not a scalar value will be returned, but an array @@ -650,15 +655,15 @@ $rowHeight = $sheet->getRowHeight(1); echo $rowHeight; // Example: 15 ``` -## Freeze Pane Configuration -Retrieve the freeze pane configuration for a sheet: +## Freeze Pane Info +Retrieve the freeze pane info for a sheet: ```php $excel = Excel::open($file); $sheet = $excel->selectSheet('SheetName'); // Get the freeze pane configuration -$freezePaneConfig = $sheet->getFreezePaneConfig(); +$freezePaneConfig = $sheet->getFreezePaneInfo(); print_r($freezePaneConfig); /* @@ -672,8 +677,8 @@ Array */ ``` -## Tab Color Configuration -Retrieve the tab color settings for a sheet: +## Tab Color Info +Retrieve the tab color info for a sheet: ```php Copy code @@ -681,7 +686,7 @@ $excel = Excel::open($file); $sheet = $excel->selectSheet('SheetName'); // Get the tab color configuration -$tabColorConfig = $sheet->getTabColorConfiguration(); +$tabColorConfig = $sheet->getTabColorInfo(); print_r($tabColorConfig); /* @@ -694,7 +699,7 @@ Array */ ``` -## Support merged cells +## Info about merged cells You can use the following methods: diff --git a/src/FastExcelReader/Sheet.php b/src/FastExcelReader/Sheet.php index 0817a7a..212b7d6 100644 --- a/src/FastExcelReader/Sheet.php +++ b/src/FastExcelReader/Sheet.php @@ -76,6 +76,7 @@ class Sheet implements InterfaceSheetReader protected ?array $tabProperties = null; + public function __construct($sheetName, $sheetId, $file, $path, $excel) { $this->excel = $excel; @@ -1830,6 +1831,7 @@ public function getColumnWidth(int $colNumber): ?float * Returns row height for a specific row number. * * @param int $rowNumber + * * @return float|null */ public function getRowHeight(int $rowNumber): ?float @@ -1841,11 +1843,11 @@ public function getRowHeight(int $rowNumber): ?float } /** - * Parses and retrieves frozen pane configuration from the sheet XML. + * Parses and retrieves frozen pane info from the sheet XML * * @return array|null */ - public function getFreezePaneConfig(): ?array + public function getFreezePaneInfo(): ?array { $xmlReader = $this->getReader(); $xmlReader->openZip($this->pathInZip); @@ -1866,11 +1868,21 @@ public function getFreezePaneConfig(): ?array break; } } - $xmlReader->close(); + return $freezePane; } + /** + * Alias of getFreezePaneInfo() + * + * @return array|null + */ + public function getFreezePaneConfig0(): ?array + { + return $this->readCells(); + } + /** * Extracts the tab properties from the sheet XML * @@ -1918,17 +1930,27 @@ protected function _readTabProperties(): void } /** - * Returns the tab color configuration of the sheet + * Returns the tab color info of the sheet * Contains any of: rgb, theme, tint, indexed * * @return array|null */ - public function getTabColorConfiguration(): ?array + public function getTabColorInfo(): ?array { if ($this->tabProperties === null) { $this->_readTabProperties(); } - return $this->tabProperties['color']; + return $this->tabProperties['color'] ?? null; + } + + /** + * Alias of getTabColorConfig() + * + * @return array|null + */ + public function getTabColorConfiguration(): ?array + { + return $this->getTabColorInfo(); } } \ No newline at end of file diff --git a/tests/FastExcelReaderTest.php b/tests/FastExcelReaderTest.php index b6bcb47..0d34883 100644 --- a/tests/FastExcelReaderTest.php +++ b/tests/FastExcelReaderTest.php @@ -432,7 +432,7 @@ public function testGetFreezePane(): void { $file = self::DEMO_DIR . 'demo-07-size-freeze-tabs.xlsx'; $excel = Excel::open($file); - $freezePane = $excel->selectSheet('report')->getFreezePaneConfig(); + $freezePane = $excel->selectSheet('report')->getFreezePaneInfo(); $this->assertEquals([ 'xSplit' => 0, @@ -441,11 +441,11 @@ public function testGetFreezePane(): void ], $freezePane); } - public function testGetTabColorConfig(): void + public function testGetTabColorInfo(): void { $file = self::DEMO_DIR . 'demo-07-size-freeze-tabs.xlsx'; $excel = Excel::open($file); - $config = $excel->selectSheet('report')->getTabColorConfiguration(); + $config = $excel->selectSheet('report')->getTabColorInfo(); $this->assertEquals([ 'theme' => '2',