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
ea006163
Commit
ea006163
authored
Mar 01, 2017
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug 30804
add support AVERAGEIFS function
parent
3a458862
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
4 deletions
+98
-4
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+2
-2
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+96
-2
No files found.
cell/model/FormulaObjects/mathematicFunctions.js
View file @
ea006163
...
...
@@ -4099,9 +4099,8 @@ cSQRTPI.prototype.getInfo = function () {
}
}
var
_sum
=
0
;
var
arg0Matrix
=
arg0
.
getMatrix
();
var
i
,
j
,
arg1
,
arg2
,
valueForSearching
,
match
,
search
,
oper
=
null
;
var
i
,
j
,
arg1
,
arg2
,
valueForSearching
,
match
,
search
,
oper
;
for
(
var
k
=
1
;
k
<
arg
.
length
;
k
+=
2
)
{
arg1
=
arg
[
k
];
arg2
=
arg
[
k
+
1
];
...
...
@@ -4156,6 +4155,7 @@ cSQRTPI.prototype.getInfo = function () {
}
}
var
_sum
=
0
;
var
valMatrix0
;
for
(
i
=
0
;
i
<
arg0Matrix
.
length
;
++
i
)
{
for
(
j
=
0
;
j
<
arg0Matrix
[
i
].
length
;
++
j
)
{
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
ea006163
...
...
@@ -639,10 +639,104 @@
/** @constructor */
function
cAVERAGEIFS
()
{
cBaseFunction
.
call
(
this
,
"
AVERAGEIFS
"
);
this
.
name
=
"
AVERAGEIFS
"
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
argumentsMin
=
3
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
255
;
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
};
this
.
numFormat
=
this
.
formatType
.
def
;
}
cAVERAGEIFS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cAVERAGEIFS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
if
(
cElementType
.
cell
!==
arg0
.
type
&&
cElementType
.
cell3D
!==
arg0
.
type
&&
cElementType
.
cellsRange
!==
arg0
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
var
arg0Matrix
=
arg0
.
getMatrix
();
var
i
,
j
,
arg1
,
arg2
,
operators
,
match
,
search
,
oper
,
valueForSearching
;
for
(
var
k
=
1
;
k
<
arg
.
length
;
k
+=
2
)
{
arg1
=
arg
[
k
];
arg2
=
arg
[
k
+
1
];
if
((
cElementType
.
cell
!==
arg1
.
type
&&
cElementType
.
cell3D
!==
arg1
.
type
&&
cElementType
.
cellsRange
!==
arg1
.
type
))
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
if
(
cElementType
.
cellsRange
===
arg2
.
type
||
cElementType
.
cellsRange3D
===
arg2
.
type
)
{
arg2
=
arg2
.
cross
(
arguments
[
1
].
bbox
);
}
else
if
(
cElementType
.
array
===
arg2
.
type
)
{
arg2
=
arg2
.
getElementRowCol
(
0
,
0
);
}
arg2
=
arg2
.
tocString
();
if
(
cElementType
.
string
!==
arg2
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg2
=
arg2
.
toString
();
operators
=
new
RegExp
(
"
^ *[<=> ]+ *
"
);
match
=
arg2
.
match
(
operators
);
if
(
match
)
{
search
=
arg2
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
arg2
;
oper
=
null
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
for
(
i
=
0
;
i
<
arg1Matrix
.
length
;
++
i
)
{
if
(
arg0Matrix
[
i
].
length
!==
arg1Matrix
[
i
].
length
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
for
(
j
=
0
;
j
<
arg1Matrix
[
i
].
length
;
++
j
)
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
AscCommonExcel
.
matching
(
arg1Matrix
[
i
][
j
],
valueForSearching
,
oper
))
{
arg0Matrix
[
i
][
j
]
=
null
;
}
}
}
}
var
_sum
=
0
,
_count
=
0
;
var
valMatrix0
;
for
(
i
=
0
;
i
<
arg0Matrix
.
length
;
++
i
)
{
for
(
j
=
0
;
j
<
arg0Matrix
[
i
].
length
;
++
j
)
{
if
((
valMatrix0
=
arg0Matrix
[
i
][
j
])
&&
cElementType
.
number
===
valMatrix0
.
type
)
{
_sum
+=
valMatrix0
.
getValue
();
++
_count
;
}
}
}
if
(
0
===
_count
)
{
return
new
cError
(
cErrorType
.
division_by_zero
);
}
else
{
return
this
.
value
=
new
cNumber
(
_sum
/
_count
);
}
};
cAVERAGEIFS
.
prototype
.
checkArguments
=
function
()
{
return
1
===
this
.
argumentsCurrent
%
2
&&
cBaseFunction
.
prototype
.
checkArguments
.
apply
(
this
,
arguments
);
};
cAVERAGEIFS
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
(average_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
"
};
};
/** @constructor */
function
cBETADIST
()
{
/*Нет реализации в Google Docs*/
...
...
@@ -1166,12 +1260,12 @@
arg1
=
arg1
.
toString
();
match
=
arg1
.
match
(
operators
);
oper
=
null
;
if
(
match
)
{
search
=
arg1
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
arg1
;
oper
=
null
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
arg1Matrix
=
arg0
.
getMatrix
();
...
...
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