chengkun
2025-06-05 4080b5997b38ca84b3b203c7101dcadb97b76925
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
 
namespace PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting;
 
class ConditionalDataBarExtension
{
    /** <dataBar> attributes */
    private int $minLength;
 
    private int $maxLength;
 
    private ?bool $border = null;
 
    private ?bool $gradient = null;
 
    private ?string $direction = null;
 
    private ?bool $negativeBarBorderColorSameAsPositive = null;
 
    private ?string $axisPosition = null;
 
    // <dataBar> children
 
    private ConditionalFormatValueObject $maximumConditionalFormatValueObject;
 
    private ConditionalFormatValueObject $minimumConditionalFormatValueObject;
 
    private ?string $borderColor = null;
 
    private ?string $negativeFillColor = null;
 
    private ?string $negativeBorderColor = null;
 
    private array $axisColor = [
        'rgb' => null,
        'theme' => null,
        'tint' => null,
    ];
 
    public function getXmlAttributes(): array
    {
        $ret = [];
        foreach (['minLength', 'maxLength', 'direction', 'axisPosition'] as $attrKey) {
            if (null !== $this->{$attrKey}) {
                $ret[$attrKey] = $this->{$attrKey};
            }
        }
        foreach (['border', 'gradient', 'negativeBarBorderColorSameAsPositive'] as $attrKey) {
            if (null !== $this->{$attrKey}) {
                $ret[$attrKey] = $this->{$attrKey} ? '1' : '0';
            }
        }
 
        return $ret;
    }
 
    public function getXmlElements(): array
    {
        $ret = [];
        $elms = ['borderColor', 'negativeFillColor', 'negativeBorderColor'];
        foreach ($elms as $elmKey) {
            if (null !== $this->{$elmKey}) {
                $ret[$elmKey] = ['rgb' => $this->{$elmKey}];
            }
        }
        foreach (array_filter($this->axisColor) as $attrKey => $axisColorAttr) {
            if (!isset($ret['axisColor'])) {
                $ret['axisColor'] = [];
            }
            $ret['axisColor'][$attrKey] = $axisColorAttr;
        }
 
        return $ret;
    }
 
    public function getMinLength(): int
    {
        return $this->minLength;
    }
 
    public function setMinLength(int $minLength): self
    {
        $this->minLength = $minLength;
 
        return $this;
    }
 
    public function getMaxLength(): int
    {
        return $this->maxLength;
    }
 
    public function setMaxLength(int $maxLength): self
    {
        $this->maxLength = $maxLength;
 
        return $this;
    }
 
    public function getBorder(): ?bool
    {
        return $this->border;
    }
 
    public function setBorder(bool $border): self
    {
        $this->border = $border;
 
        return $this;
    }
 
    public function getGradient(): ?bool
    {
        return $this->gradient;
    }
 
    public function setGradient(bool $gradient): self
    {
        $this->gradient = $gradient;
 
        return $this;
    }
 
    public function getDirection(): ?string
    {
        return $this->direction;
    }
 
    public function setDirection(string $direction): self
    {
        $this->direction = $direction;
 
        return $this;
    }
 
    public function getNegativeBarBorderColorSameAsPositive(): ?bool
    {
        return $this->negativeBarBorderColorSameAsPositive;
    }
 
    public function setNegativeBarBorderColorSameAsPositive(bool $negativeBarBorderColorSameAsPositive): self
    {
        $this->negativeBarBorderColorSameAsPositive = $negativeBarBorderColorSameAsPositive;
 
        return $this;
    }
 
    public function getAxisPosition(): ?string
    {
        return $this->axisPosition;
    }
 
    public function setAxisPosition(string $axisPosition): self
    {
        $this->axisPosition = $axisPosition;
 
        return $this;
    }
 
    public function getMaximumConditionalFormatValueObject(): ConditionalFormatValueObject
    {
        return $this->maximumConditionalFormatValueObject;
    }
 
    public function setMaximumConditionalFormatValueObject(ConditionalFormatValueObject $maximumConditionalFormatValueObject): self
    {
        $this->maximumConditionalFormatValueObject = $maximumConditionalFormatValueObject;
 
        return $this;
    }
 
    public function getMinimumConditionalFormatValueObject(): ConditionalFormatValueObject
    {
        return $this->minimumConditionalFormatValueObject;
    }
 
    public function setMinimumConditionalFormatValueObject(ConditionalFormatValueObject $minimumConditionalFormatValueObject): self
    {
        $this->minimumConditionalFormatValueObject = $minimumConditionalFormatValueObject;
 
        return $this;
    }
 
    public function getBorderColor(): ?string
    {
        return $this->borderColor;
    }
 
    public function setBorderColor(string $borderColor): self
    {
        $this->borderColor = $borderColor;
 
        return $this;
    }
 
    public function getNegativeFillColor(): ?string
    {
        return $this->negativeFillColor;
    }
 
    public function setNegativeFillColor(string $negativeFillColor): self
    {
        $this->negativeFillColor = $negativeFillColor;
 
        return $this;
    }
 
    public function getNegativeBorderColor(): ?string
    {
        return $this->negativeBorderColor;
    }
 
    public function setNegativeBorderColor(string $negativeBorderColor): self
    {
        $this->negativeBorderColor = $negativeBorderColor;
 
        return $this;
    }
 
    public function getAxisColor(): array
    {
        return $this->axisColor;
    }
 
    public function setAxisColor(mixed $rgb, mixed $theme = null, mixed $tint = null): self
    {
        $this->axisColor = [
            'rgb' => $rgb,
            'theme' => $theme,
            'tint' => $tint,
        ];
 
        return $this;
    }
}