zhaojs
2023-08-02 6bf09b5ad960fd4e657c132f9e451c487aa4d9c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
 
namespace PhpOffice\PhpSpreadsheet\Worksheet;
 
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 
abstract class CellIterator implements \Iterator
{
    /**
     * Worksheet to iterate.
     *
     * @var Worksheet
     */
    protected $worksheet;
 
    /**
     * Iterate only existing cells.
     *
     * @var bool
     */
    protected $onlyExistingCells = false;
 
    /**
     * Destructor.
     */
    public function __destruct()
    {
        unset($this->worksheet);
    }
 
    /**
     * Get loop only existing cells.
     *
     * @return bool
     */
    public function getIterateOnlyExistingCells()
    {
        return $this->onlyExistingCells;
    }
 
    /**
     * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary.
     *
     * @throws PhpSpreadsheetException
     */
    abstract protected function adjustForExistingOnlyRange();
 
    /**
     * Set the iterator to loop only existing cells.
     *
     * @param bool $value
     *
     * @throws PhpSpreadsheetException
     */
    public function setIterateOnlyExistingCells($value)
    {
        $this->onlyExistingCells = (bool) $value;
 
        $this->adjustForExistingOnlyRange();
    }
}