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
6ae175a7
Commit
6ae175a7
authored
Jun 08, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function in range getValues and getValuesAndMap
fix bug 32608
parent
d60a72dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
37 deletions
+67
-37
cell/model/Workbook.js
cell/model/Workbook.js
+27
-10
cell/model/autofilters.js
cell/model/autofilters.js
+40
-27
No files found.
cell/model/Workbook.js
View file @
6ae175a7
...
...
@@ -3532,17 +3532,8 @@ Woorksheet.prototype.initPostOpen = function(handlers){
this
.
_setHandlersTablePart
();
};
Woorksheet
.
prototype
.
_getValuesForConditionalFormatting
=
function
(
sqref
,
withEmpty
)
{
var
res
=
[];
var
range
=
this
.
getRange3
(
sqref
.
r1
,
sqref
.
c1
,
sqref
.
r2
,
sqref
.
c2
);
var
fAction
=
function
(
c
)
{
res
.
push
({
c
:
c
,
v
:
c
.
getValueWithoutFormat
()});
};
if
(
withEmpty
)
{
range
.
_setProperty
(
null
,
null
,
fAction
);
}
else
{
range
.
_setPropertyNoEmpty
(
null
,
null
,
fAction
);
}
return
res
;
return
range
.
_getValues
(
withEmpty
);
};
Woorksheet
.
prototype
.
_updateConditionalFormatting
=
function
(
range
)
{
var
oGradient1
,
oGradient2
;
...
...
@@ -6506,6 +6497,32 @@ Range.prototype._getRangeType=function(oBBox){
oBBox
=
this
.
bbox
;
return
getRangeType
(
oBBox
);
};
Range
.
prototype
.
_getValues
=
function
(
withEmpty
)
{
var
res
=
[];
var
fAction
=
function
(
c
)
{
res
.
push
({
c
:
c
,
v
:
c
.
getValueWithoutFormat
()});
};
if
(
withEmpty
)
{
this
.
_setProperty
(
null
,
null
,
fAction
);
}
else
{
this
.
_setPropertyNoEmpty
(
null
,
null
,
fAction
);
}
return
res
;
};
Range
.
prototype
.
_getValuesAndMap
=
function
(
withEmpty
)
{
var
v
,
arrRes
=
[],
mapRes
=
{};
var
fAction
=
function
(
c
)
{
v
=
c
.
getValueWithoutFormat
();
arrRes
.
push
({
c
:
c
,
v
:
v
});
mapRes
[
v
.
toLowerCase
()]
=
true
;
};
if
(
withEmpty
)
{
this
.
_setProperty
(
null
,
null
,
fAction
);
}
else
{
this
.
_setPropertyNoEmpty
(
null
,
null
,
fAction
);
}
return
{
values
:
arrRes
,
map
:
mapRes
};
};
Range
.
prototype
.
_setProperty
=
function
(
actionRow
,
actionCol
,
actionCell
){
var
nRangeType
=
this
.
_getRangeType
();
if
(
c_oRangeType
.
Range
==
nRangeType
)
...
...
cell/model/autofilters.js
View file @
6ae175a7
...
...
@@ -4044,36 +4044,49 @@
return
result
;
},
_generateColumnNameWithoutTitle
:
function
(
r
ange
)
_generateColumnNameWithoutTitle
:
function
(
r
ef
)
{
var
worksheet
=
this
.
worksheet
;
var
newTableColumn
;
var
tableColumns
=
[];
var
cell
;
var
val
;
for
(
var
col1
=
range
.
c1
;
col1
<=
range
.
c2
;
col1
++
)
{
cell
=
worksheet
.
getCell3
(
range
.
r1
,
col1
);
val
=
cell
.
getValue
();
//если ячейка пустая, то генерируем название
if
(
val
==
''
)
val
=
this
.
_generateColumnName
(
tableColumns
);
//проверяем, не повторяется ли значение, которое лежит в данной ячейке
var
index
=
2
;
var
valNew
=
val
;
for
(
var
s
=
0
;
s
<
tableColumns
.
length
;
s
++
)
{
if
(
valNew
==
tableColumns
[
s
].
Name
)
{
valNew
=
val
+
index
;
index
++
;
s
=
-
1
;
var
tableColumns
=
[],
newTableColumn
;
var
range
=
this
.
worksheet
.
getRange3
(
ref
.
r1
,
ref
.
c1
,
ref
.
r1
,
ref
.
c2
);
var
defaultName
=
'
Column
'
;
var
uniqueColumns
=
{},
val
,
valTemplate
,
valLower
,
index
=
1
,
isDuplicate
=
false
,
emptyCells
=
false
;
var
valuesAndMap
=
range
.
_getValuesAndMap
(
true
);
var
values
=
valuesAndMap
.
values
;
var
length
=
values
.
length
;
if
(
0
===
length
)
{
// Выделили всю строку без значений
length
=
ref
.
c2
-
ref
.
c1
+
1
;
emptyCells
=
true
;
}
var
map
=
valuesAndMap
.
map
;
for
(
var
i
=
0
;
i
<
length
;
++
i
)
{
if
(
emptyCells
||
''
===
(
valTemplate
=
val
=
values
[
i
].
v
))
{
valTemplate
=
defaultName
;
val
=
valTemplate
+
index
;
++
index
;
}
while
(
true
)
{
if
(
isDuplicate
)
{
val
=
valTemplate
+
(
++
index
);
}
valLower
=
val
.
toLowerCase
();
if
(
uniqueColumns
[
valLower
])
{
isDuplicate
=
true
;
}
else
{
if
(
isDuplicate
&&
map
[
valLower
])
{
continue
;
}
uniqueColumns
[
valLower
]
=
true
;
newTableColumn
=
new
AscCommonExcel
.
TableColumn
();
newTableColumn
.
Name
=
val
;
tableColumns
.
push
(
newTableColumn
);
isDuplicate
=
false
;
break
;
}
}
newTableColumn
=
new
AscCommonExcel
.
TableColumn
();
newTableColumn
.
Name
=
valNew
;
tableColumns
[
col1
-
range
.
c1
]
=
newTableColumn
;
}
return
tableColumns
;
},
...
...
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