2388 |
jpm |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* PHPExcel
|
|
|
4 |
*
|
|
|
5 |
* Copyright (c) 2006 - 2013 PHPExcel
|
|
|
6 |
*
|
|
|
7 |
* This library is free software; you can redistribute it and/or
|
|
|
8 |
* modify it under the terms of the GNU Lesser General Public
|
|
|
9 |
* License as published by the Free Software Foundation; either
|
|
|
10 |
* version 2.1 of the License, or (at your option) any later version.
|
|
|
11 |
*
|
|
|
12 |
* This library is distributed in the hope that it will be useful,
|
|
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
15 |
* Lesser General Public License for more details.
|
|
|
16 |
*
|
|
|
17 |
* You should have received a copy of the GNU Lesser General Public
|
|
|
18 |
* License along with this library; if not, write to the Free Software
|
|
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
20 |
*
|
|
|
21 |
* @category PHPExcel
|
|
|
22 |
* @package PHPExcel_Worksheet
|
|
|
23 |
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
|
24 |
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
|
25 |
* @version ##VERSION##, ##DATE##
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
31 |
*
|
|
|
32 |
* @category PHPExcel
|
|
|
33 |
* @package PHPExcel_Worksheet
|
|
|
34 |
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
|
35 |
*/
|
|
|
36 |
class PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
37 |
{
|
|
|
38 |
const AUTOFILTER_RULETYPE_FILTER = 'filter';
|
|
|
39 |
const AUTOFILTER_RULETYPE_DATEGROUP = 'dateGroupItem';
|
|
|
40 |
const AUTOFILTER_RULETYPE_CUSTOMFILTER = 'customFilter';
|
|
|
41 |
const AUTOFILTER_RULETYPE_DYNAMICFILTER = 'dynamicFilter';
|
|
|
42 |
const AUTOFILTER_RULETYPE_TOPTENFILTER = 'top10Filter';
|
|
|
43 |
|
|
|
44 |
private static $_ruleTypes = array(
|
|
|
45 |
// Currently we're not handling
|
|
|
46 |
// colorFilter
|
|
|
47 |
// extLst
|
|
|
48 |
// iconFilter
|
|
|
49 |
self::AUTOFILTER_RULETYPE_FILTER,
|
|
|
50 |
self::AUTOFILTER_RULETYPE_DATEGROUP,
|
|
|
51 |
self::AUTOFILTER_RULETYPE_CUSTOMFILTER,
|
|
|
52 |
self::AUTOFILTER_RULETYPE_DYNAMICFILTER,
|
|
|
53 |
self::AUTOFILTER_RULETYPE_TOPTENFILTER,
|
|
|
54 |
);
|
|
|
55 |
|
|
|
56 |
const AUTOFILTER_RULETYPE_DATEGROUP_YEAR = 'year';
|
|
|
57 |
const AUTOFILTER_RULETYPE_DATEGROUP_MONTH = 'month';
|
|
|
58 |
const AUTOFILTER_RULETYPE_DATEGROUP_DAY = 'day';
|
|
|
59 |
const AUTOFILTER_RULETYPE_DATEGROUP_HOUR = 'hour';
|
|
|
60 |
const AUTOFILTER_RULETYPE_DATEGROUP_MINUTE = 'minute';
|
|
|
61 |
const AUTOFILTER_RULETYPE_DATEGROUP_SECOND = 'second';
|
|
|
62 |
|
|
|
63 |
private static $_dateTimeGroups = array(
|
|
|
64 |
self::AUTOFILTER_RULETYPE_DATEGROUP_YEAR,
|
|
|
65 |
self::AUTOFILTER_RULETYPE_DATEGROUP_MONTH,
|
|
|
66 |
self::AUTOFILTER_RULETYPE_DATEGROUP_DAY,
|
|
|
67 |
self::AUTOFILTER_RULETYPE_DATEGROUP_HOUR,
|
|
|
68 |
self::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE,
|
|
|
69 |
self::AUTOFILTER_RULETYPE_DATEGROUP_SECOND,
|
|
|
70 |
);
|
|
|
71 |
|
|
|
72 |
const AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY = 'yesterday';
|
|
|
73 |
const AUTOFILTER_RULETYPE_DYNAMIC_TODAY = 'today';
|
|
|
74 |
const AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW = 'tomorrow';
|
|
|
75 |
const AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE = 'yearToDate';
|
|
|
76 |
const AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR = 'thisYear';
|
|
|
77 |
const AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER = 'thisQuarter';
|
|
|
78 |
const AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH = 'thisMonth';
|
|
|
79 |
const AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK = 'thisWeek';
|
|
|
80 |
const AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR = 'lastYear';
|
|
|
81 |
const AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER = 'lastQuarter';
|
|
|
82 |
const AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH = 'lastMonth';
|
|
|
83 |
const AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK = 'lastWeek';
|
|
|
84 |
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR = 'nextYear';
|
|
|
85 |
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER = 'nextQuarter';
|
|
|
86 |
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH = 'nextMonth';
|
|
|
87 |
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK = 'nextWeek';
|
|
|
88 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1 = 'M1';
|
|
|
89 |
const AUTOFILTER_RULETYPE_DYNAMIC_JANUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1;
|
|
|
90 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2 = 'M2';
|
|
|
91 |
const AUTOFILTER_RULETYPE_DYNAMIC_FEBRUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2;
|
|
|
92 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3 = 'M3';
|
|
|
93 |
const AUTOFILTER_RULETYPE_DYNAMIC_MARCH = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3;
|
|
|
94 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4 = 'M4';
|
|
|
95 |
const AUTOFILTER_RULETYPE_DYNAMIC_APRIL = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4;
|
|
|
96 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5 = 'M5';
|
|
|
97 |
const AUTOFILTER_RULETYPE_DYNAMIC_MAY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5;
|
|
|
98 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6 = 'M6';
|
|
|
99 |
const AUTOFILTER_RULETYPE_DYNAMIC_JUNE = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6;
|
|
|
100 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7 = 'M7';
|
|
|
101 |
const AUTOFILTER_RULETYPE_DYNAMIC_JULY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7;
|
|
|
102 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8 = 'M8';
|
|
|
103 |
const AUTOFILTER_RULETYPE_DYNAMIC_AUGUST = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8;
|
|
|
104 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9 = 'M9';
|
|
|
105 |
const AUTOFILTER_RULETYPE_DYNAMIC_SEPTEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9;
|
|
|
106 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10 = 'M10';
|
|
|
107 |
const AUTOFILTER_RULETYPE_DYNAMIC_OCTOBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10;
|
|
|
108 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11 = 'M11';
|
|
|
109 |
const AUTOFILTER_RULETYPE_DYNAMIC_NOVEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11;
|
|
|
110 |
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12 = 'M12';
|
|
|
111 |
const AUTOFILTER_RULETYPE_DYNAMIC_DECEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12;
|
|
|
112 |
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_1 = 'Q1';
|
|
|
113 |
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_2 = 'Q2';
|
|
|
114 |
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_3 = 'Q3';
|
|
|
115 |
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_4 = 'Q4';
|
|
|
116 |
const AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE = 'aboveAverage';
|
|
|
117 |
const AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE = 'belowAverage';
|
|
|
118 |
|
|
|
119 |
private static $_dynamicTypes = array(
|
|
|
120 |
self::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY,
|
|
|
121 |
self::AUTOFILTER_RULETYPE_DYNAMIC_TODAY,
|
|
|
122 |
self::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW,
|
|
|
123 |
self::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE,
|
|
|
124 |
self::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR,
|
|
|
125 |
self::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER,
|
|
|
126 |
self::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH,
|
|
|
127 |
self::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK,
|
|
|
128 |
self::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR,
|
|
|
129 |
self::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER,
|
|
|
130 |
self::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH,
|
|
|
131 |
self::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK,
|
|
|
132 |
self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR,
|
|
|
133 |
self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER,
|
|
|
134 |
self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH,
|
|
|
135 |
self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK,
|
|
|
136 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1,
|
|
|
137 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2,
|
|
|
138 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3,
|
|
|
139 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4,
|
|
|
140 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5,
|
|
|
141 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6,
|
|
|
142 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7,
|
|
|
143 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8,
|
|
|
144 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9,
|
|
|
145 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10,
|
|
|
146 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11,
|
|
|
147 |
self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12,
|
|
|
148 |
self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_1,
|
|
|
149 |
self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_2,
|
|
|
150 |
self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_3,
|
|
|
151 |
self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_4,
|
|
|
152 |
self::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE,
|
|
|
153 |
self::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE,
|
|
|
154 |
);
|
|
|
155 |
|
|
|
156 |
/*
|
|
|
157 |
* The only valid filter rule operators for filter and customFilter types are:
|
|
|
158 |
* <xsd:enumeration value="equal"/>
|
|
|
159 |
* <xsd:enumeration value="lessThan"/>
|
|
|
160 |
* <xsd:enumeration value="lessThanOrEqual"/>
|
|
|
161 |
* <xsd:enumeration value="notEqual"/>
|
|
|
162 |
* <xsd:enumeration value="greaterThanOrEqual"/>
|
|
|
163 |
* <xsd:enumeration value="greaterThan"/>
|
|
|
164 |
*/
|
|
|
165 |
const AUTOFILTER_COLUMN_RULE_EQUAL = 'equal';
|
|
|
166 |
const AUTOFILTER_COLUMN_RULE_NOTEQUAL = 'notEqual';
|
|
|
167 |
const AUTOFILTER_COLUMN_RULE_GREATERTHAN = 'greaterThan';
|
|
|
168 |
const AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL = 'greaterThanOrEqual';
|
|
|
169 |
const AUTOFILTER_COLUMN_RULE_LESSTHAN = 'lessThan';
|
|
|
170 |
const AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL = 'lessThanOrEqual';
|
|
|
171 |
|
|
|
172 |
private static $_operators = array(
|
|
|
173 |
self::AUTOFILTER_COLUMN_RULE_EQUAL,
|
|
|
174 |
self::AUTOFILTER_COLUMN_RULE_NOTEQUAL,
|
|
|
175 |
self::AUTOFILTER_COLUMN_RULE_GREATERTHAN,
|
|
|
176 |
self::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL,
|
|
|
177 |
self::AUTOFILTER_COLUMN_RULE_LESSTHAN,
|
|
|
178 |
self::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
|
|
|
179 |
);
|
|
|
180 |
|
|
|
181 |
const AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE = 'byValue';
|
|
|
182 |
const AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT = 'byPercent';
|
|
|
183 |
|
|
|
184 |
private static $_topTenValue = array(
|
|
|
185 |
self::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE,
|
|
|
186 |
self::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT,
|
|
|
187 |
);
|
|
|
188 |
|
|
|
189 |
const AUTOFILTER_COLUMN_RULE_TOPTEN_TOP = 'top';
|
|
|
190 |
const AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM = 'bottom';
|
|
|
191 |
|
|
|
192 |
private static $_topTenType = array(
|
|
|
193 |
self::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP,
|
|
|
194 |
self::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM,
|
|
|
195 |
);
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
/* Rule Operators (Numeric, Boolean etc) */
|
|
|
199 |
// const AUTOFILTER_COLUMN_RULE_BETWEEN = 'between'; // greaterThanOrEqual 1 && lessThanOrEqual 2
|
|
|
200 |
/* Rule Operators (Numeric Special) which are translated to standard numeric operators with calculated values */
|
|
|
201 |
// const AUTOFILTER_COLUMN_RULE_TOPTEN = 'topTen'; // greaterThan calculated value
|
|
|
202 |
// const AUTOFILTER_COLUMN_RULE_TOPTENPERCENT = 'topTenPercent'; // greaterThan calculated value
|
|
|
203 |
// const AUTOFILTER_COLUMN_RULE_ABOVEAVERAGE = 'aboveAverage'; // Value is calculated as the average
|
|
|
204 |
// const AUTOFILTER_COLUMN_RULE_BELOWAVERAGE = 'belowAverage'; // Value is calculated as the average
|
|
|
205 |
/* Rule Operators (String) which are set as wild-carded values */
|
|
|
206 |
// const AUTOFILTER_COLUMN_RULE_BEGINSWITH = 'beginsWith'; // A*
|
|
|
207 |
// const AUTOFILTER_COLUMN_RULE_ENDSWITH = 'endsWith'; // *Z
|
|
|
208 |
// const AUTOFILTER_COLUMN_RULE_CONTAINS = 'contains'; // *B*
|
|
|
209 |
// const AUTOFILTER_COLUMN_RULE_DOESNTCONTAIN = 'notEqual'; // notEqual *B*
|
|
|
210 |
/* Rule Operators (Date Special) which are translated to standard numeric operators with calculated values */
|
|
|
211 |
// const AUTOFILTER_COLUMN_RULE_BEFORE = 'lessThan';
|
|
|
212 |
// const AUTOFILTER_COLUMN_RULE_AFTER = 'greaterThan';
|
|
|
213 |
// const AUTOFILTER_COLUMN_RULE_YESTERDAY = 'yesterday';
|
|
|
214 |
// const AUTOFILTER_COLUMN_RULE_TODAY = 'today';
|
|
|
215 |
// const AUTOFILTER_COLUMN_RULE_TOMORROW = 'tomorrow';
|
|
|
216 |
// const AUTOFILTER_COLUMN_RULE_LASTWEEK = 'lastWeek';
|
|
|
217 |
// const AUTOFILTER_COLUMN_RULE_THISWEEK = 'thisWeek';
|
|
|
218 |
// const AUTOFILTER_COLUMN_RULE_NEXTWEEK = 'nextWeek';
|
|
|
219 |
// const AUTOFILTER_COLUMN_RULE_LASTMONTH = 'lastMonth';
|
|
|
220 |
// const AUTOFILTER_COLUMN_RULE_THISMONTH = 'thisMonth';
|
|
|
221 |
// const AUTOFILTER_COLUMN_RULE_NEXTMONTH = 'nextMonth';
|
|
|
222 |
// const AUTOFILTER_COLUMN_RULE_LASTQUARTER = 'lastQuarter';
|
|
|
223 |
// const AUTOFILTER_COLUMN_RULE_THISQUARTER = 'thisQuarter';
|
|
|
224 |
// const AUTOFILTER_COLUMN_RULE_NEXTQUARTER = 'nextQuarter';
|
|
|
225 |
// const AUTOFILTER_COLUMN_RULE_LASTYEAR = 'lastYear';
|
|
|
226 |
// const AUTOFILTER_COLUMN_RULE_THISYEAR = 'thisYear';
|
|
|
227 |
// const AUTOFILTER_COLUMN_RULE_NEXTYEAR = 'nextYear';
|
|
|
228 |
// const AUTOFILTER_COLUMN_RULE_YEARTODATE = 'yearToDate'; // <dynamicFilter val="40909" type="yearToDate" maxVal="41113"/>
|
|
|
229 |
// const AUTOFILTER_COLUMN_RULE_ALLDATESINMONTH = 'allDatesInMonth'; // <dynamicFilter type="M2"/> for Month/February
|
|
|
230 |
// const AUTOFILTER_COLUMN_RULE_ALLDATESINQUARTER = 'allDatesInQuarter'; // <dynamicFilter type="Q2"/> for Quarter 2
|
|
|
231 |
|
|
|
232 |
/**
|
|
|
233 |
* Autofilter Column
|
|
|
234 |
*
|
|
|
235 |
* @var PHPExcel_Worksheet_AutoFilter_Column
|
|
|
236 |
*/
|
|
|
237 |
private $_parent = NULL;
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
/**
|
|
|
241 |
* Autofilter Rule Type
|
|
|
242 |
*
|
|
|
243 |
* @var string
|
|
|
244 |
*/
|
|
|
245 |
private $_ruleType = self::AUTOFILTER_RULETYPE_FILTER;
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
/**
|
|
|
249 |
* Autofilter Rule Value
|
|
|
250 |
*
|
|
|
251 |
* @var string
|
|
|
252 |
*/
|
|
|
253 |
private $_value = '';
|
|
|
254 |
|
|
|
255 |
/**
|
|
|
256 |
* Autofilter Rule Operator
|
|
|
257 |
*
|
|
|
258 |
* @var string
|
|
|
259 |
*/
|
|
|
260 |
private $_operator = '';
|
|
|
261 |
|
|
|
262 |
/**
|
|
|
263 |
* DateTimeGrouping Group Value
|
|
|
264 |
*
|
|
|
265 |
* @var string
|
|
|
266 |
*/
|
|
|
267 |
private $_grouping = '';
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
/**
|
|
|
271 |
* Create a new PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
272 |
*
|
|
|
273 |
* @param PHPExcel_Worksheet_AutoFilter_Column $pParent
|
|
|
274 |
*/
|
|
|
275 |
public function __construct(PHPExcel_Worksheet_AutoFilter_Column $pParent = NULL)
|
|
|
276 |
{
|
|
|
277 |
$this->_parent = $pParent;
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
/**
|
|
|
281 |
* Get AutoFilter Rule Type
|
|
|
282 |
*
|
|
|
283 |
* @return string
|
|
|
284 |
*/
|
|
|
285 |
public function getRuleType() {
|
|
|
286 |
return $this->_ruleType;
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
/**
|
|
|
290 |
* Set AutoFilter Rule Type
|
|
|
291 |
*
|
|
|
292 |
* @param string $pRuleType
|
|
|
293 |
* @throws PHPExcel_Exception
|
|
|
294 |
* @return PHPExcel_Worksheet_AutoFilter_Column
|
|
|
295 |
*/
|
|
|
296 |
public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER) {
|
|
|
297 |
if (!in_array($pRuleType,self::$_ruleTypes)) {
|
|
|
298 |
throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.');
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
$this->_ruleType = $pRuleType;
|
|
|
302 |
|
|
|
303 |
return $this;
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
/**
|
|
|
307 |
* Get AutoFilter Rule Value
|
|
|
308 |
*
|
|
|
309 |
* @return string
|
|
|
310 |
*/
|
|
|
311 |
public function getValue() {
|
|
|
312 |
return $this->_value;
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
/**
|
|
|
316 |
* Set AutoFilter Rule Value
|
|
|
317 |
*
|
|
|
318 |
* @param string|string[] $pValue
|
|
|
319 |
* @throws PHPExcel_Exception
|
|
|
320 |
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
321 |
*/
|
|
|
322 |
public function setValue($pValue = '') {
|
|
|
323 |
if (is_array($pValue)) {
|
|
|
324 |
$grouping = -1;
|
|
|
325 |
foreach($pValue as $key => $value) {
|
|
|
326 |
// Validate array entries
|
|
|
327 |
if (!in_array($key,self::$_dateTimeGroups)) {
|
|
|
328 |
// Remove any invalid entries from the value array
|
|
|
329 |
unset($pValue[$key]);
|
|
|
330 |
} else {
|
|
|
331 |
// Work out what the dateTime grouping will be
|
|
|
332 |
$grouping = max($grouping,array_search($key,self::$_dateTimeGroups));
|
|
|
333 |
}
|
|
|
334 |
}
|
|
|
335 |
if (count($pValue) == 0) {
|
|
|
336 |
throw new PHPExcel_Exception('Invalid rule value for column AutoFilter Rule.');
|
|
|
337 |
}
|
|
|
338 |
// Set the dateTime grouping that we've anticipated
|
|
|
339 |
$this->setGrouping(self::$_dateTimeGroups[$grouping]);
|
|
|
340 |
}
|
|
|
341 |
$this->_value = $pValue;
|
|
|
342 |
|
|
|
343 |
return $this;
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
/**
|
|
|
347 |
* Get AutoFilter Rule Operator
|
|
|
348 |
*
|
|
|
349 |
* @return string
|
|
|
350 |
*/
|
|
|
351 |
public function getOperator() {
|
|
|
352 |
return $this->_operator;
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
/**
|
|
|
356 |
* Set AutoFilter Rule Operator
|
|
|
357 |
*
|
|
|
358 |
* @param string $pOperator
|
|
|
359 |
* @throws PHPExcel_Exception
|
|
|
360 |
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
361 |
*/
|
|
|
362 |
public function setOperator($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL) {
|
|
|
363 |
if (empty($pOperator))
|
|
|
364 |
$pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
|
|
|
365 |
if ((!in_array($pOperator,self::$_operators)) &&
|
|
|
366 |
(!in_array($pOperator,self::$_topTenValue))) {
|
|
|
367 |
throw new PHPExcel_Exception('Invalid operator for column AutoFilter Rule.');
|
|
|
368 |
}
|
|
|
369 |
$this->_operator = $pOperator;
|
|
|
370 |
|
|
|
371 |
return $this;
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
/**
|
|
|
375 |
* Get AutoFilter Rule Grouping
|
|
|
376 |
*
|
|
|
377 |
* @return string
|
|
|
378 |
*/
|
|
|
379 |
public function getGrouping() {
|
|
|
380 |
return $this->_grouping;
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
/**
|
|
|
384 |
* Set AutoFilter Rule Grouping
|
|
|
385 |
*
|
|
|
386 |
* @param string $pGrouping
|
|
|
387 |
* @throws PHPExcel_Exception
|
|
|
388 |
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
389 |
*/
|
|
|
390 |
public function setGrouping($pGrouping = NULL) {
|
|
|
391 |
if (($pGrouping !== NULL) &&
|
|
|
392 |
(!in_array($pGrouping,self::$_dateTimeGroups)) &&
|
|
|
393 |
(!in_array($pGrouping,self::$_dynamicTypes)) &&
|
|
|
394 |
(!in_array($pGrouping,self::$_topTenType))) {
|
|
|
395 |
throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.');
|
|
|
396 |
}
|
|
|
397 |
|
|
|
398 |
$this->_grouping = $pGrouping;
|
|
|
399 |
|
|
|
400 |
return $this;
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
/**
|
|
|
404 |
* Set AutoFilter Rule
|
|
|
405 |
*
|
|
|
406 |
* @param string $pOperator
|
|
|
407 |
* @param string|string[] $pValue
|
|
|
408 |
* @param string $pGrouping
|
|
|
409 |
* @throws PHPExcel_Exception
|
|
|
410 |
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
411 |
*/
|
|
|
412 |
public function setRule($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL, $pValue = '', $pGrouping = NULL) {
|
|
|
413 |
$this->setOperator($pOperator);
|
|
|
414 |
$this->setValue($pValue);
|
|
|
415 |
// Only set grouping if it's been passed in as a user-supplied argument,
|
|
|
416 |
// otherwise we're calculating it when we setValue() and don't want to overwrite that
|
|
|
417 |
// If the user supplies an argumnet for grouping, then on their own head be it
|
|
|
418 |
if ($pGrouping !== NULL)
|
|
|
419 |
$this->setGrouping($pGrouping);
|
|
|
420 |
|
|
|
421 |
return $this;
|
|
|
422 |
}
|
|
|
423 |
|
|
|
424 |
/**
|
|
|
425 |
* Get this Rule's AutoFilter Column Parent
|
|
|
426 |
*
|
|
|
427 |
* @return PHPExcel_Worksheet_AutoFilter_Column
|
|
|
428 |
*/
|
|
|
429 |
public function getParent() {
|
|
|
430 |
return $this->_parent;
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
/**
|
|
|
434 |
* Set this Rule's AutoFilter Column Parent
|
|
|
435 |
*
|
|
|
436 |
* @param PHPExcel_Worksheet_AutoFilter_Column
|
|
|
437 |
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule
|
|
|
438 |
*/
|
|
|
439 |
public function setParent(PHPExcel_Worksheet_AutoFilter_Column $pParent = NULL) {
|
|
|
440 |
$this->_parent = $pParent;
|
|
|
441 |
|
|
|
442 |
return $this;
|
|
|
443 |
}
|
|
|
444 |
|
|
|
445 |
/**
|
|
|
446 |
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
|
|
447 |
*/
|
|
|
448 |
public function __clone() {
|
|
|
449 |
$vars = get_object_vars($this);
|
|
|
450 |
foreach ($vars as $key => $value) {
|
|
|
451 |
if (is_object($value)) {
|
|
|
452 |
if ($key == '_parent') {
|
|
|
453 |
// Detach from autofilter column parent
|
|
|
454 |
$this->$key = NULL;
|
|
|
455 |
} else {
|
|
|
456 |
$this->$key = clone $value;
|
|
|
457 |
}
|
|
|
458 |
} else {
|
|
|
459 |
$this->$key = $value;
|
|
|
460 |
}
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
}
|