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
6ca440df
Commit
6ca440df
authored
Mar 28, 2016
by
GoshaZotov
Committed by
Alexander.Trofimov
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
добавил сортировку по цвету текста и цвету ячейки(изменил функию Range.prototype.sort)
parent
dabf4223
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
26 deletions
+97
-26
cell/model/Workbook.js
cell/model/Workbook.js
+97
-26
No files found.
cell/model/Workbook.js
View file @
6ca440df
...
...
@@ -8280,7 +8280,7 @@ Range.prototype.cleanHyperlinks=function(){
this
.
removeHyperlink
(
aHyperlinks
.
inner
[
i
].
data
);
History
.
EndTransaction
();
};
Range
.
prototype
.
sort
=
function
(
nOption
,
nStartCol
){
Range
.
prototype
.
sort
=
function
(
nOption
,
nStartCol
,
colorText
,
colorFill
){
//todo горизонтальная сортировка
var
aMerged
=
this
.
worksheet
.
mergeManager
.
get
(
this
.
bbox
);
if
(
aMerged
.
outer
.
length
>
0
||
(
aMerged
.
inner
.
length
>
0
&&
null
==
_isSameSizeMerged
(
this
.
bbox
,
aMerged
.
inner
)))
...
...
@@ -8336,6 +8336,23 @@ Range.prototype.sort=function(nOption, nStartCol){
if
(
nLastRow0
<
nRow0
)
nLastRow0
=
nRow0
;
var
val
=
oCell
.
getValueWithoutFormat
();
//for sort color
var
colorFillCell
,
colorsTextCell
=
null
;
if
(
colorFill
)
{
var
styleCell
=
oCell
.
getStyle
();
colorFillCell
=
styleCell
!==
null
?
styleCell
.
fill
:
null
;
}
else
if
(
colorText
)
{
var
value2
=
oCell
.
getValue2
();
for
(
var
n
=
0
;
n
<
value2
.
length
;
n
++
)
{
colorsTextCell
.
push
(
value2
[
n
].
c
);
}
}
var
nNumber
=
null
;
var
sText
=
null
;
if
(
""
!=
val
)
...
...
@@ -8345,7 +8362,11 @@ Range.prototype.sort=function(nOption, nStartCol){
nNumber
=
nVal
;
else
sText
=
val
;
aSortElems
.
push
({
row
:
nRow0
,
num
:
nNumber
,
text
:
sText
});
aSortElems
.
push
({
row
:
nRow0
,
num
:
nNumber
,
text
:
sText
,
colorFill
:
colorFillCell
,
colorsText
:
colorsTextCell
});
}
else
if
(
colorFill
||
colorText
)
{
aSortElems
.
push
({
row
:
nRow0
,
num
:
nNumber
,
text
:
sText
,
colorFill
:
colorFillCell
,
colorsText
:
colorsTextCell
});
}
}
}
...
...
@@ -8375,6 +8396,54 @@ Range.prototype.sort=function(nOption, nStartCol){
function
strcmp
(
str1
,
str2
)
{
return
(
(
str1
==
str2
)
?
0
:
(
(
str1
>
str2
)
?
1
:
-
1
)
);
}
//color sort
var
colorFillCmp
=
function
(
color1
,
color2
)
{
var
res
=
false
;
if
(
colorFill
)
{
res
=
color1
!==
null
&&
color2
!==
null
&&
color1
.
isEqual
(
color2
)
===
true
?
true
:
false
;
}
else
if
(
colorText
&&
color1
&&
color1
.
length
)
{
for
(
var
n
=
0
;
n
<
color1
.
length
;
n
++
)
{
if
(
color1
[
n
]
&&
color1
[
n
].
isEqual
(
color2
))
{
res
=
true
;
break
;
}
}
}
return
res
;
};
if
(
colorText
||
colorFill
)
{
var
newArrayNeedColor
=
[];
var
newArrayAnotherColor
=
[];
var
sortColor
=
colorText
?
colorText
:
colorFill
;
for
(
var
i
=
0
;
i
<
aSortElems
.
length
;
i
++
)
{
var
color
=
colorFill
?
aSortElems
[
i
].
colorFill
:
aSortElems
[
i
].
colorText
;
if
(
colorFillCmp
(
color
,
sortColor
))
{
newArrayNeedColor
.
push
(
aSortElems
[
i
]);
}
else
{
newArrayAnotherColor
.
push
(
aSortElems
[
i
]);
}
}
aSortElems
=
newArrayAnotherColor
.
concat
(
newArrayNeedColor
);
}
else
{
aSortElems
.
sort
(
function
(
a
,
b
){
var
res
=
0
;
if
(
null
!=
a
.
text
)
...
...
@@ -8397,6 +8466,8 @@ Range.prototype.sort=function(nOption, nStartCol){
res
=
-
res
;
return
res
;
});
}
//проверяем что это не пустая операция
var
aSortData
=
[];
var
nHiddenCount
=
0
;
...
...
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