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\XLSX;
6
 
7
use OpenSpout\Common\Entity\Style\Style;
8
use OpenSpout\Writer\Common\AbstractOptions;
9
use OpenSpout\Writer\XLSX\Options\HeaderFooter;
10
use OpenSpout\Writer\XLSX\Options\PageMargin;
11
use OpenSpout\Writer\XLSX\Options\PageSetup;
12
 
13
final class Options extends AbstractOptions
14
{
15
    public const DEFAULT_FONT_SIZE = 12;
16
    public const DEFAULT_FONT_NAME = 'Calibri';
17
 
18
    public bool $SHOULD_USE_INLINE_STRINGS = true;
19
 
20
    /** @var MergeCell[] */
21
    private array $MERGE_CELLS = [];
22
 
23
    private ?PageMargin $pageMargin = null;
24
 
25
    private ?PageSetup $pageSetup = null;
26
 
27
    private ?HeaderFooter $headerFooter = null;
28
 
29
    public function __construct()
30
    {
31
        parent::__construct();
32
 
33
        $defaultRowStyle = new Style();
34
        $defaultRowStyle->setFontSize(self::DEFAULT_FONT_SIZE);
35
        $defaultRowStyle->setFontName(self::DEFAULT_FONT_NAME);
36
 
37
        $this->DEFAULT_ROW_STYLE = $defaultRowStyle;
38
    }
39
 
40
    /**
41
     * Row coordinates are indexed from 1, columns from 0 (A = 0),
42
     * so a merge B2:G2 looks like $writer->mergeCells(1, 2, 6, 2);.
43
     *
44
     * @param 0|positive-int $topLeftColumn
45
     * @param positive-int   $topLeftRow
46
     * @param 0|positive-int $bottomRightColumn
47
     * @param positive-int   $bottomRightRow
48
     * @param 0|positive-int $sheetIndex
49
     */
50
    public function mergeCells(
51
        int $topLeftColumn,
52
        int $topLeftRow,
53
        int $bottomRightColumn,
54
        int $bottomRightRow,
55
        int $sheetIndex = 0,
56
    ): void {
57
        $this->MERGE_CELLS[] = new MergeCell(
58
            $sheetIndex,
59
            $topLeftColumn,
60
            $topLeftRow,
61
            $bottomRightColumn,
62
            $bottomRightRow
63
        );
64
    }
65
 
66
    /**
67
     * @return MergeCell[]
68
     *
69
     * @internal
70
     */
71
    public function getMergeCells(): array
72
    {
73
        return $this->MERGE_CELLS;
74
    }
75
 
76
    public function setPageMargin(PageMargin $pageMargin): void
77
    {
78
        $this->pageMargin = $pageMargin;
79
    }
80
 
81
    public function getPageMargin(): ?PageMargin
82
    {
83
        return $this->pageMargin;
84
    }
85
 
86
    public function setPageSetup(PageSetup $pageSetup): void
87
    {
88
        $this->pageSetup = $pageSetup;
89
    }
90
 
91
    public function getPageSetup(): ?PageSetup
92
    {
93
        return $this->pageSetup;
94
    }
95
 
96
    public function setHeaderFooter(HeaderFooter $headerFooter): void
97
    {
98
        $this->headerFooter = $headerFooter;
99
    }
100
 
101
    public function getHeaderFooter(): ?HeaderFooter
102
    {
103
        return $this->headerFooter;
104
    }
105
}