Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aVadim483 committed Nov 30, 2024
1 parent 637966c commit 9fe99da
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
/*
Expand All @@ -672,16 +677,16 @@ 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
$excel = Excel::open($file);
$sheet = $excel->selectSheet('SheetName');

// Get the tab color configuration
$tabColorConfig = $sheet->getTabColorConfiguration();
$tabColorConfig = $sheet->getTabColorInfo();

print_r($tabColorConfig);
/*
Expand All @@ -694,7 +699,7 @@ Array
*/
```

## Support merged cells
## Info about merged cells

You can use the following methods:

Expand Down
34 changes: 28 additions & 6 deletions src/FastExcelReader/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Sheet implements InterfaceSheetReader

protected ?array $tabProperties = null;


public function __construct($sheetName, $sheetId, $file, $path, $excel)
{
$this->excel = $excel;
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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
*
Expand Down Expand Up @@ -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();
}
}
6 changes: 3 additions & 3 deletions tests/FastExcelReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand Down

0 comments on commit 9fe99da

Please sign in to comment.