Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
f21228bd
Commit
f21228bd
authored
May 13, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support top10 in conditional formatting
parent
0e04bf2a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
20 deletions
+45
-20
cell/model/Workbook.js
cell/model/Workbook.js
+45
-20
No files found.
cell/model/Workbook.js
View file @
f21228bd
...
@@ -1901,7 +1901,7 @@ function angleInterfaceToFormat(val)
...
@@ -1901,7 +1901,7 @@ function angleInterfaceToFormat(val)
function
getUniqueKeys
(
array
)
{
function
getUniqueKeys
(
array
)
{
var
i
,
o
=
{};
var
i
,
o
=
{};
for
(
i
=
0
;
i
<
array
.
length
;
++
i
)
{
for
(
i
=
0
;
i
<
array
.
length
;
++
i
)
{
o
[
array
[
i
]
]
=
o
.
hasOwnProperty
(
array
[
i
]
);
o
[
array
[
i
]
.
v
]
=
o
.
hasOwnProperty
(
array
[
i
].
v
);
}
}
return
o
;
return
o
;
}
}
...
@@ -3480,15 +3480,14 @@ Woorksheet.prototype.initPostOpen = function(handlers){
...
@@ -3480,15 +3480,14 @@ Woorksheet.prototype.initPostOpen = function(handlers){
this
.
_setHandlersTablePart
();
this
.
_setHandlersTablePart
();
};
};
Woorksheet
.
prototype
.
_getValuesForConditionalFormatting
=
function
(
sqref
)
{
Woorksheet
.
prototype
.
_getValuesForConditionalFormatting
=
function
(
sqref
)
{
var
res
=
[];
var
aValues
=
[],
aCells
=
[];
var
aValues
=
[],
aCells
=
[];
var
tmp
;
this
.
getRange3
(
sqref
.
r1
,
sqref
.
c1
,
sqref
.
r2
,
sqref
.
c2
).
_setPropertyNoEmpty
(
null
,
null
,
function
(
c
)
{
this
.
getRange3
(
sqref
.
r1
,
sqref
.
c1
,
sqref
.
r2
,
sqref
.
c2
).
_setPropertyNoEmpty
(
null
,
null
,
function
(
c
)
{
if
(
!
c
.
isEmptyTextString
())
{
if
(
!
c
.
isEmptyTextString
())
{
aCells
.
push
(
c
);
res
.
push
({
c
:
c
,
v
:
c
.
getValueWithoutFormat
()});
aValues
.
push
(
c
.
getValueWithoutFormat
());
}
}
});
});
return
{
c
:
aCells
,
v
:
aValues
}
;
return
res
;
};
};
Woorksheet
.
prototype
.
_updateConditionalFormatting
=
function
(
range
)
{
Woorksheet
.
prototype
.
_updateConditionalFormatting
=
function
(
range
)
{
var
oGradient
=
null
;
var
oGradient
=
null
;
...
@@ -3496,7 +3495,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3496,7 +3495,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
,
compareFunction
;
var
i
,
j
,
cell
,
sqref
,
values
,
value
,
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)
...
@@ -3508,9 +3507,9 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3508,9 +3507,9 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
for
(
j
=
0
;
j
<
aRules
.
length
;
++
j
)
{
for
(
j
=
0
;
j
<
aRules
.
length
;
++
j
)
{
oRule
=
aRules
[
j
];
oRule
=
aRules
[
j
];
// ToDo aboveAverage,
beginsWith,
cellIs, containsBlanks, containsErrors,
// ToDo aboveAverage, cellIs, containsBlanks, containsErrors,
// ToDo dataBar, e
ndsWith, e
xpression, iconSet, notContainsBlanks,
// ToDo dataBar, expression, iconSet, notContainsBlanks,
// ToDo notContainsErrors, timePeriod
, top10
(page 2679)
// ToDo notContainsErrors, timePeriod (page 2679)
if
(
Asc
.
ECfType
.
colorScale
===
oRule
.
type
)
{
if
(
Asc
.
ECfType
.
colorScale
===
oRule
.
type
)
{
if
(
1
!==
oRule
.
aRuleElements
.
length
)
{
if
(
1
!==
oRule
.
aRuleElements
.
length
)
{
break
;
break
;
...
@@ -3523,28 +3522,54 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3523,28 +3522,54 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
max
=
-
Number
.
MAX_VALUE
;
max
=
-
Number
.
MAX_VALUE
;
values
=
this
.
_getValuesForConditionalFormatting
(
sqref
);
values
=
this
.
_getValuesForConditionalFormatting
(
sqref
);
for
(
cell
=
0
;
cell
<
values
.
v
.
length
;
++
cell
)
{
for
(
cell
=
0
;
cell
<
values
.
v
.
length
;
++
cell
)
{
if
(
CellValueType
.
Number
===
values
.
c
[
cell
].
getType
()
&&
!
isNaN
(
tmp
=
parseFloat
(
values
.
v
[
cell
])))
{
value
=
values
[
cell
];
values
.
v
[
cell
]
=
tmp
;
if
(
CellValueType
.
Number
===
value
.
c
.
getType
()
&&
!
isNaN
(
tmp
=
parseFloat
(
value
.
v
)))
{
value
.
v
=
tmp
;
min
=
Math
.
min
(
min
,
tmp
);
min
=
Math
.
min
(
min
,
tmp
);
max
=
Math
.
max
(
max
,
tmp
);
max
=
Math
.
max
(
max
,
tmp
);
}
else
{
}
else
{
value
s
.
v
[
cell
]
=
null
;
value
.
v
=
null
;
}
}
}
}
// ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681)
// ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681)
// ToDo support 3 colors in rule
// ToDo support 3 colors in rule
if
(
0
<
values
.
c
.
length
&&
2
===
oRuleElement
.
aColors
.
length
)
{
if
(
0
<
values
.
length
&&
2
===
oRuleElement
.
aColors
.
length
)
{
oGradient
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
0
],
oRuleElement
.
aColors
[
1
]);
oGradient
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
0
],
oRuleElement
.
aColors
[
1
]);
oGradient
.
init
(
min
,
max
);
oGradient
.
init
(
min
,
max
);
for
(
cell
=
0
;
cell
<
values
.
c
.
length
;
++
cell
)
{
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
value
=
values
[
cell
];
dxf
=
null
;
dxf
=
null
;
if
(
null
!==
value
s
.
v
[
cell
]
)
{
if
(
null
!==
value
.
v
)
{
dxf
=
new
AscCommonExcel
.
CellXfs
();
dxf
=
new
AscCommonExcel
.
CellXfs
();
dxf
.
fill
=
new
AscCommonExcel
.
Fill
({
bg
:
oGradient
.
calculateColor
(
values
.
v
[
cell
])});
dxf
.
fill
=
new
AscCommonExcel
.
Fill
({
bg
:
oGradient
.
calculateColor
(
value
.
v
)});
}
value
.
c
.
setConditionalFormattingStyle
(
dxf
);
}
}
}
values
.
c
[
cell
].
setConditionalFormattingStyle
(
dxf
);
}
else
if
(
Asc
.
ECfType
.
top10
===
oRule
.
type
)
{
if
(
oRule
.
rank
>
0
&&
oRule
.
dxf
)
{
values
=
this
.
_getValuesForConditionalFormatting
(
sqref
);
o
=
oRule
.
bottom
?
-
Number
.
MAX_VALUE
:
Number
.
MAX_VALUE
;
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
value
=
values
[
cell
];
if
(
CellValueType
.
Number
===
value
.
c
.
getType
()
&&
!
isNaN
(
tmp
=
parseFloat
(
value
.
v
)))
{
value
.
v
=
tmp
;
}
else
{
value
.
v
=
o
;
}
}
values
.
sort
((
function
(
condition
)
{
return
function
(
v1
,
v2
)
{
return
condition
*
(
v2
.
v
-
v1
.
v
);
}
})(
oRule
.
bottom
?
-
1
:
1
));
tmp
=
0
;
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
value
=
values
[
cell
];
value
.
c
.
setConditionalFormattingStyle
((
o
!==
value
.
v
&&
tmp
<
oRule
.
rank
)
?
(
++
tmp
&&
oRule
.
dxf
)
:
null
);
}
}
}
}
}
else
{
}
else
{
...
@@ -3556,7 +3581,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3556,7 +3581,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
switch
(
oRule
.
type
)
{
switch
(
oRule
.
type
)
{
case
Asc
.
ECfType
.
duplicateValues
:
case
Asc
.
ECfType
.
duplicateValues
:
case
Asc
.
ECfType
.
uniqueValues
:
case
Asc
.
ECfType
.
uniqueValues
:
o
=
getUniqueKeys
(
values
.
v
);
o
=
getUniqueKeys
(
values
);
compareFunction
=
(
function
(
obj
,
condition
){
compareFunction
=
(
function
(
obj
,
condition
){
return
function
(
val
)
{
return
function
(
val
)
{
return
condition
===
obj
[
val
];
return
condition
===
obj
[
val
];
...
@@ -3597,8 +3622,8 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3597,8 +3622,8 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
break
;
break
;
}
}
for
(
cell
=
0
;
cell
<
values
.
c
.
length
;
++
cell
)
{
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
values
.
c
[
cell
].
setConditionalFormattingStyle
(
compareFunction
(
values
.
v
[
cell
]
)
?
oRule
.
dxf
:
null
);
values
[
cell
].
c
.
setConditionalFormattingStyle
(
compareFunction
(
values
[
cell
].
v
)
?
oRule
.
dxf
:
null
);
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment