Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace OpenSpout\Reader\XLSX;
6
 
7
use OpenSpout\Reader\Common\ColumnWidth;
1441 ariadna 8
use OpenSpout\Reader\SheetWithMergeCellsInterface;
1 efrain 9
use OpenSpout\Reader\SheetWithVisibilityInterface;
10
 
11
/**
12
 * @implements SheetWithVisibilityInterface<RowIterator>
1441 ariadna 13
 * @implements SheetWithMergeCellsInterface<RowIterator>
1 efrain 14
 */
1441 ariadna 15
final readonly class Sheet implements SheetWithVisibilityInterface, SheetWithMergeCellsInterface
1 efrain 16
{
17
    /** @var RowIterator To iterate over sheet's rows */
1441 ariadna 18
    private RowIterator $rowIterator;
1 efrain 19
 
20
    /** @var SheetHeaderReader To read the header of the sheet, containing for instance the col widths */
1441 ariadna 21
    private SheetHeaderReader $headerReader;
1 efrain 22
 
23
    /** @var int Index of the sheet, based on order in the workbook (zero-based) */
1441 ariadna 24
    private int $index;
1 efrain 25
 
26
    /** @var string Name of the sheet */
1441 ariadna 27
    private string $name;
1 efrain 28
 
29
    /** @var bool Whether the sheet was the active one */
1441 ariadna 30
    private bool $isActive;
1 efrain 31
 
32
    /** @var bool Whether the sheet is visible */
1441 ariadna 33
    private bool $isVisible;
1 efrain 34
 
1441 ariadna 35
    /** @var list<string> Merge cells list ["C7:E7", "A9:D10"] */
36
    private array $mergeCells;
37
 
1 efrain 38
    /**
1441 ariadna 39
     * @param RowIterator  $rowIterator    The corresponding row iterator
40
     * @param int          $sheetIndex     Index of the sheet, based on order in the workbook (zero-based)
41
     * @param string       $sheetName      Name of the sheet
42
     * @param bool         $isSheetActive  Whether the sheet was defined as active
43
     * @param bool         $isSheetVisible Whether the sheet is visible
44
     * @param list<string> $mergeCells     Merge cells list ["C7:E7", "A9:D10"]
1 efrain 45
     */
1441 ariadna 46
    public function __construct(
47
        RowIterator $rowIterator,
48
        SheetHeaderReader $headerReader,
49
        int $sheetIndex,
50
        string $sheetName,
51
        bool $isSheetActive,
52
        bool $isSheetVisible,
53
        array $mergeCells
54
    ) {
1 efrain 55
        $this->rowIterator = $rowIterator;
56
        $this->headerReader = $headerReader;
57
        $this->index = $sheetIndex;
58
        $this->name = $sheetName;
59
        $this->isActive = $isSheetActive;
60
        $this->isVisible = $isSheetVisible;
1441 ariadna 61
        $this->mergeCells = $mergeCells;
1 efrain 62
    }
63
 
64
    public function getRowIterator(): RowIterator
65
    {
66
        return $this->rowIterator;
67
    }
68
 
69
    /**
70
     * @return ColumnWidth[] a list of column-widths
71
     */
72
    public function getColumnWidths(): array
73
    {
74
        return $this->headerReader->getColumnWidths();
75
    }
76
 
77
    /**
78
     * @return int Index of the sheet, based on order in the workbook (zero-based)
79
     */
80
    public function getIndex(): int
81
    {
82
        return $this->index;
83
    }
84
 
85
    /**
86
     * @return string Name of the sheet
87
     */
88
    public function getName(): string
89
    {
90
        return $this->name;
91
    }
92
 
93
    /**
94
     * @return bool Whether the sheet was defined as active
95
     */
96
    public function isActive(): bool
97
    {
98
        return $this->isActive;
99
    }
100
 
101
    /**
102
     * @return bool Whether the sheet is visible
103
     */
104
    public function isVisible(): bool
105
    {
106
        return $this->isVisible;
107
    }
1441 ariadna 108
 
109
    /**
110
     * @return list<string> Merge cells list ["C7:E7", "A9:D10"]
111
     */
112
    public function getMergeCells(): array
113
    {
114
        return $this->mergeCells;
115
    }
1 efrain 116
}