Proyectos de Subversion Moodle

Rev

| 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\Writer\Common\Entity;
6
 
7
/**
8
 * Entity describing a Worksheet.
9
 */
10
final class Worksheet
11
{
12
    /** @var string Path to the XML file that will contain the sheet data */
13
    private readonly string $filePath;
14
 
15
    /** @var null|resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
16
    private $filePointer;
17
 
18
    /** @var Sheet The "external" sheet */
19
    private readonly Sheet $externalSheet;
20
 
21
    /** @var int Maximum number of columns among all the written rows */
22
    private int $maxNumColumns = 0;
23
 
24
    /** @var int Index of the last written row */
25
    private int $lastWrittenRowIndex = 0;
26
 
27
    /**
28
     * Worksheet constructor.
29
     */
30
    public function __construct(string $worksheetFilePath, Sheet $externalSheet)
31
    {
32
        $this->filePath = $worksheetFilePath;
33
        $this->externalSheet = $externalSheet;
34
    }
35
 
36
    public function getFilePath(): string
37
    {
38
        return $this->filePath;
39
    }
40
 
41
    /**
42
     * @return resource
43
     */
44
    public function getFilePointer()
45
    {
46
        \assert(null !== $this->filePointer);
47
 
48
        return $this->filePointer;
49
    }
50
 
51
    /**
52
     * @param resource $filePointer
53
     */
54
    public function setFilePointer($filePointer): void
55
    {
56
        $this->filePointer = $filePointer;
57
    }
58
 
59
    public function getExternalSheet(): Sheet
60
    {
61
        return $this->externalSheet;
62
    }
63
 
64
    public function getMaxNumColumns(): int
65
    {
66
        return $this->maxNumColumns;
67
    }
68
 
69
    public function setMaxNumColumns(int $maxNumColumns): void
70
    {
71
        $this->maxNumColumns = $maxNumColumns;
72
    }
73
 
74
    public function getLastWrittenRowIndex(): int
75
    {
76
        return $this->lastWrittenRowIndex;
77
    }
78
 
79
    public function setLastWrittenRowIndex(int $lastWrittenRowIndex): void
80
    {
81
        $this->lastWrittenRowIndex = $lastWrittenRowIndex;
82
    }
83
 
84
    /**
85
     * @return int The ID of the worksheet
86
     */
87
    public function getId(): int
88
    {
89
        // sheet index is zero-based, while ID is 1-based
90
        return $this->externalSheet->getIndex() + 1;
91
    }
92
}