Commit 0e04bf2a authored by Alexander.Trofimov's avatar Alexander.Trofimov

support endsWith and beginsWith in conditional formatting

parent a6db9cd2
...@@ -939,7 +939,8 @@ ...@@ -939,7 +939,8 @@
notContainsText: 13, notContainsText: 13,
timePeriod: 14, timePeriod: 14,
top10: 15, top10: 15,
uniqueValues: 16 uniqueValues: 16,
endsWith: 17
}; };
/** @enum */ /** @enum */
var EIconSetType = var EIconSetType =
......
...@@ -3496,7 +3496,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3496,7 +3496,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
var aRules, oRule; var aRules, oRule;
var oRuleElement = null; var oRuleElement = null;
var o; var o;
var i, j, cell, sqref, values, tmp, min, max, dxf, condition; var i, j, cell, sqref, values, tmp, min, max, dxf, compareFunction;
for (i = 0; i < aCFs.length; ++i) { for (i = 0; i < aCFs.length; ++i) {
sqref = aCFs[i].sqref; sqref = aCFs[i].sqref;
// ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx) // ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
...@@ -3511,8 +3511,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3511,8 +3511,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
// ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors, // ToDo aboveAverage, beginsWith, cellIs, containsBlanks, containsErrors,
// ToDo dataBar, endsWith, expression, iconSet, notContainsBlanks, // ToDo dataBar, endsWith, expression, iconSet, notContainsBlanks,
// ToDo notContainsErrors, timePeriod, top10 (page 2679) // ToDo notContainsErrors, timePeriod, top10 (page 2679)
switch (oRule.type) { if (Asc.ECfType.colorScale === oRule.type) {
case Asc.ECfType.colorScale:
if (1 !== oRule.aRuleElements.length) { if (1 !== oRule.aRuleElements.length) {
break; break;
} }
...@@ -3548,28 +3547,59 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) { ...@@ -3548,28 +3547,59 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
values.c[cell].setConditionalFormattingStyle(dxf); values.c[cell].setConditionalFormattingStyle(dxf);
} }
} }
break; } else {
if (!oRule.dxf) {
continue;
}
values = this._getValuesForConditionalFormatting(sqref);
switch (oRule.type) {
case Asc.ECfType.duplicateValues: case Asc.ECfType.duplicateValues:
case Asc.ECfType.uniqueValues: case Asc.ECfType.uniqueValues:
if (oRule.dxf) {
condition = oRule.type === Asc.ECfType.uniqueValues;
values = this._getValuesForConditionalFormatting(sqref);
o = getUniqueKeys(values.v); o = getUniqueKeys(values.v);
for (cell = 0; cell < values.c.length; ++cell) { compareFunction = (function(obj, condition){
values.c[cell].setConditionalFormattingStyle((condition === o[values.v[cell]]) ? null : oRule.dxf); return function(val) {
} return condition === obj[val];
} };
})(o, oRule.type === Asc.ECfType.duplicateValues);
break; break;
case Asc.ECfType.containsText: case Asc.ECfType.containsText:
compareFunction = (function(text){
return function(val) {
return -1 !== val.indexOf(text);
};
})(oRule.text);
break;
case Asc.ECfType.notContainsText: case Asc.ECfType.notContainsText:
if (oRule.dxf) { compareFunction = (function(text){
condition = oRule.type === Asc.ECfType.containsText; return function(val) {
values = this._getValuesForConditionalFormatting(sqref); return -1 === val.indexOf(text);
for (cell = 0; cell < values.c.length; ++cell) { };
values.c[cell].setConditionalFormattingStyle((condition === (-1 === values.v[cell].indexOf(oRule.text))) ? null : oRule.dxf); })(oRule.text);
break;
case Asc.ECfType.beginsWith:
compareFunction = (function(text){
return function(val) {
return val.startsWith(text);
};
})(oRule.text);
break;
case Asc.ECfType.endsWith:
compareFunction = (function(text){
return function(val) {
return val.endsWith(text);
};
})(oRule.text);
break;
default:
continue;
break;
} }
for (cell = 0; cell < values.c.length; ++cell) {
values.c[cell].setConditionalFormattingStyle(compareFunction(values.v[cell]) ? oRule.dxf : null);
} }
break;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment