Update 2024-10-08 05:05:31

This commit is contained in:
Robot 2024-10-08 05:04:50 +02:00
parent 492bab1f36
commit 43edf4dee7
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
7 changed files with 21 additions and 20 deletions

View File

@ -8,15 +8,14 @@
``` ```
# final class ChunkReadFilter (Details) # final class ChunkReadFilter (Details)
> namespace: **VDM\Joomla\Componentbuilder\Spreadsheet** > namespace: **VDM\Joomla\Componentbuilder\Spreadsheet**
> extends: **IReadFilter**
```uml ```uml
@startuml @startuml
class ChunkReadFilter << (F,LightGreen) >> #RoyalBlue { class ChunkReadFilter << (F,LightGreen) >> #RoyalBlue {
- $startRow - int $startRow
- $endRow - int $endRow
+ __construct(int $startRow, int $chunkSize) + __construct(int $startRow, int $chunkSize)
+ readCell(string $column, int $row, ...) : bool + readCell(string $columnAddress, int $row, ...) : bool
} }
note right of ChunkReadFilter::__construct note right of ChunkReadFilter::__construct
@ -30,9 +29,9 @@ note right of ChunkReadFilter::readCell
return: bool return: bool
arguments: arguments:
string $column string $columnAddress
int $row int $row
string|null $worksheetName = null string $worksheetName = ''
end note end note
@enduml @enduml

View File

@ -20,14 +20,14 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
* *
* @since 3.2.0 * @since 3.2.0
*/ */
final class ChunkReadFilter extends IReadFilter final class ChunkReadFilter implements IReadFilter
{ {
/** /**
* The first row to read in the current chunk. * The first row to read in the current chunk.
* *
* @var int * @var int
*/ */
private $startRow; private int $startRow;
/** /**
* The last row to read in the current chunk. * The last row to read in the current chunk.
@ -35,7 +35,7 @@ final class ChunkReadFilter extends IReadFilter
* *
* @var int * @var int
*/ */
private $endRow; private int $endRow;
/** /**
* Constructor to initialize the chunk filter. * Constructor to initialize the chunk filter.
@ -58,7 +58,7 @@ final class ChunkReadFilter extends IReadFilter
* *
* @return bool Whether the cell should be read. * @return bool Whether the cell should be read.
*/ */
public function readCell($column, $row, $worksheetName = null) public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool
{ {
// Only read rows that fall within the chunk range // Only read rows that fall within the chunk range
if ($row >= $this->startRow && $row <= $this->endRow) if ($row >= $this->startRow && $row <= $this->endRow)

View File

@ -3,7 +3,7 @@
* *
* @var int * @var int
*/ */
private $startRow; private int $startRow;
/** /**
* The last row to read in the current chunk. * The last row to read in the current chunk.
@ -11,7 +11,7 @@
* *
* @var int * @var int
*/ */
private $endRow; private int $endRow;
/** /**
* Constructor to initialize the chunk filter. * Constructor to initialize the chunk filter.
@ -34,7 +34,7 @@
* *
* @return bool Whether the cell should be read. * @return bool Whether the cell should be read.
*/ */
public function readCell($column, $row, $worksheetName = null) public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool
{ {
// Only read rows that fall within the chunk range // Only read rows that fall within the chunk range
if ($row >= $this->startRow && $row <= $this->endRow) if ($row >= $this->startRow && $row <= $this->endRow)

View File

@ -1,9 +1,11 @@
{ {
"add_head": "0", "add_head": "0",
"add_licensing_template": "2", "add_licensing_template": "2",
"extends": "-1", "extends": "",
"guid": "9ae018a5-9064-40ed-ad69-9c1ed2a459f5", "guid": "9ae018a5-9064-40ed-ad69-9c1ed2a459f5",
"implements": null, "implements": [
"-1"
],
"load_selection": null, "load_selection": null,
"name": "ChunkReadFilter", "name": "ChunkReadFilter",
"power_version": "1.0.0", "power_version": "1.0.0",
@ -13,7 +15,7 @@
"extendsinterfaces": null, "extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Spreadsheet.ChunkReadFilter", "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Spreadsheet.ChunkReadFilter",
"description": "Chunk Read Filter Class\r\n\r\n@since 3.2.0", "description": "Chunk Read Filter Class\r\n\r\n@since 3.2.0",
"extends_custom": "IReadFilter", "implements_custom": "IReadFilter",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
"head": "", "head": "",
"composer": { "composer": {

View File

@ -27,10 +27,10 @@
"namespace0": { "namespace0": {
"use": "PhpOffice\\PhpSpreadsheet\\IOFactory" "use": "PhpOffice\\PhpSpreadsheet\\IOFactory"
}, },
"namespace2": { "namespace1": {
"use": "PhpOffice\\PhpSpreadsheet\\Reader\\Exception as ReaderException" "use": "PhpOffice\\PhpSpreadsheet\\Reader\\Exception as ReaderException"
}, },
"namespace3": { "namespace2": {
"use": "PhpOffice\\PhpSpreadsheet\\Exception as SpreadsheetException" "use": "PhpOffice\\PhpSpreadsheet\\Exception as SpreadsheetException"
} }
} }

View File

@ -40,7 +40,7 @@ final class Header
} }
try { try {
$chunkFilter = new ChunkReadFilter(20, 1); $chunkFilter = new ChunkReadFilter(1, 20);
$inputFileType = IOFactory::identify($filePath); $inputFileType = IOFactory::identify($filePath);
$reader = IOFactory::createReader($inputFileType); $reader = IOFactory::createReader($inputFileType);
$reader->setReadFilter($chunkFilter); $reader->setReadFilter($chunkFilter);

View File

@ -15,7 +15,7 @@
} }
try { try {
$chunkFilter = new ChunkReadFilter(20, 1); $chunkFilter = new ChunkReadFilter(1, 20);
$inputFileType = IOFactory::identify($filePath); $inputFileType = IOFactory::identify($filePath);
$reader = IOFactory::createReader($inputFileType); $reader = IOFactory::createReader($inputFileType);
$reader->setReadFilter($chunkFilter); $reader->setReadFilter($chunkFilter);