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
d5bf4a6a
Commit
d5bf4a6a
authored
Jul 26, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MINIFS formula
parent
da8e88fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
7 deletions
+145
-7
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+32
-0
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+113
-7
No files found.
cell/.unit-tests/FormulaTests.js
View file @
d5bf4a6a
...
@@ -2355,6 +2355,38 @@ $( function () {
...
@@ -2355,6 +2355,38 @@ $( function () {
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
}
);
}
);
test
(
"
Test:
\"
MINIFS
\"
"
,
function
()
{
ws
.
getRange2
(
"
AAA2
"
).
setValue
(
"
10
"
);
ws
.
getRange2
(
"
AAA3
"
).
setValue
(
"
1
"
);
ws
.
getRange2
(
"
AAA4
"
).
setValue
(
"
100
"
);
ws
.
getRange2
(
"
AAA5
"
).
setValue
(
"
1
"
);
ws
.
getRange2
(
"
AAA6
"
).
setValue
(
"
1
"
);
ws
.
getRange2
(
"
AAA7
"
).
setValue
(
"
50
"
);
ws
.
getRange2
(
"
BBB2
"
).
setValue
(
"
b
"
);
ws
.
getRange2
(
"
BBB3
"
).
setValue
(
"
a
"
);
ws
.
getRange2
(
"
BBB4
"
).
setValue
(
"
a
"
);
ws
.
getRange2
(
"
BBB5
"
).
setValue
(
"
b
"
);
ws
.
getRange2
(
"
BBB6
"
).
setValue
(
"
a
"
);
ws
.
getRange2
(
"
BBB7
"
).
setValue
(
"
b
"
);
ws
.
getRange2
(
"
DDD2
"
).
setValue
(
"
100
"
);
ws
.
getRange2
(
"
DDD3
"
).
setValue
(
"
100
"
);
ws
.
getRange2
(
"
DDD4
"
).
setValue
(
"
200
"
);
ws
.
getRange2
(
"
DDD5
"
).
setValue
(
"
300
"
);
ws
.
getRange2
(
"
DDD6
"
).
setValue
(
"
100
"
);
ws
.
getRange2
(
"
DDD7
"
).
setValue
(
"
400
"
);
oParser
=
new
parserFormula
(
'
MINIFS(AAA2:AAA7,BBB2:BBB7,"b",DDD2:DDD7,">100")
'
,
"
A22
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
'
MINIFS(AAA2:AAA6,BBB2:BBB6,"a",DDD2:DDD6,">200")
'
,
"
A22
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
}
);
test
(
"
Test:
\"
TEXT
\"
"
,
function
()
{
test
(
"
Test:
\"
TEXT
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
"
TEXT(1234.567,
\"
$0.00
\"
)
"
,
"
A2
"
,
ws
);
oParser
=
new
parserFormula
(
"
TEXT(1234.567,
\"
$0.00
\"
)
"
,
"
A2
"
,
ws
);
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
d5bf4a6a
...
@@ -67,13 +67,14 @@
...
@@ -67,13 +67,14 @@
cEXPON_DIST
,
cEXPONDIST
,
cF_DIST
,
cFDIST
,
cF_DIST_RT
,
cF_INV
,
cFINV
,
cF_INV_RT
,
cFISHER
,
cFISHERINV
,
cFORECAST
,
cEXPON_DIST
,
cEXPONDIST
,
cF_DIST
,
cFDIST
,
cF_DIST_RT
,
cF_INV
,
cFINV
,
cF_INV_RT
,
cFISHER
,
cFISHERINV
,
cFORECAST
,
cFORECAST_LINEAR
,
cFREQUENCY
,
cFTEST
,
cGAMMA
,
cGAMMA_DIST
,
cGAMMADIST
,
cGAMMA_INV
,
cGAMMAINV
,
cGAMMALN
,
cFORECAST_LINEAR
,
cFREQUENCY
,
cFTEST
,
cGAMMA
,
cGAMMA_DIST
,
cGAMMADIST
,
cGAMMA_INV
,
cGAMMAINV
,
cGAMMALN
,
cGAMMALN_PRECISE
,
cGAUSS
,
cGEOMEAN
,
cGROWTH
,
cHARMEAN
,
cHYPGEOMDIST
,
cINTERCEPT
,
cKURT
,
cLARGE
,
cLINEST
,
cGAMMALN_PRECISE
,
cGAUSS
,
cGEOMEAN
,
cGROWTH
,
cHARMEAN
,
cHYPGEOMDIST
,
cINTERCEPT
,
cKURT
,
cLARGE
,
cLINEST
,
cLOGEST
,
cLOGINV
,
cLOGNORM_DIST
,
cLOGNORM_INV
,
cLOGNORMDIST
,
cMAX
,
cMAXA
,
cMAXIFS
,
cMEDIAN
,
cMIN
,
cMINA
,
cMODE
,
cLOGEST
,
cLOGINV
,
cLOGNORM_DIST
,
cLOGNORM_INV
,
cLOGNORMDIST
,
cMAX
,
cMAXA
,
cMAXIFS
,
cMEDIAN
,
cMIN
,
cMINA
,
cMODE_MULT
,
cMODE_SNGL
,
cNEGBINOMDIST
,
cNEGBINOM_DIST
,
cNORMDIST
,
cNORM_DIST
,
cNORMINV
,
cNORM_INV
,
cNORMSDIST
,
cMINIFS
,
cMODE
,
cMODE_MULT
,
cMODE_SNGL
,
cNEGBINOMDIST
,
cNEGBINOM_DIST
,
cNORMDIST
,
cNORM_DIST
,
cNORMINV
,
cNORM_S_DIST
,
cNORMSINV
,
cNORM_S_INV
,
cPEARSON
,
cPERCENTILE
,
cPERCENTILE_EXC
,
cPERCENTILE_INC
,
cPERCENTRANK
,
cNORM_INV
,
cNORMSDIST
,
cNORM_S_DIST
,
cNORMSINV
,
cNORM_S_INV
,
cPEARSON
,
cPERCENTILE
,
cPERCENTILE_EXC
,
cPERCENTRANK_EXC
,
cPERCENTRANK_INC
,
cPERMUT
,
cPERMUTATIONA
,
cPHI
,
cPOISSON
,
cPOISSON_DIST
,
cPROB
,
cQUARTILE
,
cPERCENTILE_INC
,
cPERCENTRANK
,
cPERCENTRANK_EXC
,
cPERCENTRANK_INC
,
cPERMUT
,
cPERMUTATIONA
,
cPHI
,
cPOISSON
,
cQUARTILE_EXC
,
cQUARTILE_INC
,
cRANK
,
cRANK_AVG
,
cRANK_EQ
,
cRSQ
,
cSKEW
,
cSKEW_P
,
cSLOPE
,
cSMALL
,
cSTANDARDIZE
,
cPOISSON_DIST
,
cPROB
,
cQUARTILE
,
cQUARTILE_EXC
,
cQUARTILE_INC
,
cRANK
,
cRANK_AVG
,
cRANK_EQ
,
cRSQ
,
cSKEW
,
cSKEW_P
,
cSTDEV
,
cSTDEV_S
,
cSTDEVA
,
cSTDEVP
,
cSTDEV_P
,
cSTDEVPA
,
cSTEYX
,
cTDIST
,
cT_DIST
,
cT_DIST_2T
,
cT_DIST_RT
,
cT_INV
,
cSLOPE
,
cSMALL
,
cSTANDARDIZE
,
cSTDEV
,
cSTDEV_S
,
cSTDEVA
,
cSTDEVP
,
cSTDEV_P
,
cSTDEVPA
,
cSTEYX
,
cTDIST
,
cT_DIST
,
cT_INV_2T
,
cTINV
,
cTREND
,
cTRIMMEAN
,
cTTEST
,
cT_TEST
,
cVAR
,
cVARA
,
cVARP
,
cVAR_P
,
cVAR_S
,
cVARPA
,
cWEIBULL
,
cT_DIST_2T
,
cT_DIST_RT
,
cT_INV
,
cT_INV_2T
,
cTINV
,
cTREND
,
cTRIMMEAN
,
cTTEST
,
cT_TEST
,
cVAR
,
cVARA
,
cVARP
,
cVAR_P
,
cVAR_S
,
cVARPA
,
cWEIBULL
,
cWEIBULL_DIST
,
cZTEST
,
cZ_TEST
);
cWEIBULL_DIST
,
cZTEST
,
cZ_TEST
);
cFormulaFunctionGroup
[
'
NotRealised
'
]
=
cFormulaFunctionGroup
[
'
NotRealised
'
]
||
[];
cFormulaFunctionGroup
[
'
NotRealised
'
]
=
cFormulaFunctionGroup
[
'
NotRealised
'
]
||
[];
...
@@ -5114,6 +5115,111 @@
...
@@ -5114,6 +5115,111 @@
return
1
===
this
.
argumentsCurrent
%
2
&&
cBaseFunction
.
prototype
.
checkArguments
.
apply
(
this
,
arguments
);
return
1
===
this
.
argumentsCurrent
%
2
&&
cBaseFunction
.
prototype
.
checkArguments
.
apply
(
this
,
arguments
);
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cMINIFS
()
{
this
.
name
=
"
MINIFS
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cMINIFS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cMINIFS
.
prototype
.
constructor
=
cMINIFS
;
cMINIFS
.
prototype
.
argumentsMin
=
3
;
cMINIFS
.
prototype
.
isXLFN
=
true
;
cMINIFS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
if
(
cElementType
.
cell
!==
arg0
.
type
&&
cElementType
.
cell3D
!==
arg0
.
type
&&
cElementType
.
cellsRange
!==
arg0
.
type
)
{
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
tocArea
();
if
(
!
arg0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
var
arg0Matrix
=
arg0
.
getMatrix
();
var
i
,
j
,
arg1
,
arg2
,
matchingInfo
;
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
)
{
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
)
{
arg1
=
arg1
.
tocArea
();
if
(
!
arg1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
if
(
cElementType
.
cellsRange
===
arg2
.
type
||
cElementType
.
cellsRange3D
===
arg2
.
type
)
{
arg2
=
arg2
.
cross
(
arguments
[
1
]);
}
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
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
());
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
//compare
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
],
matchingInfo
))
{
//MS считает в данном случае, что значение 0 (из диапазона условий) соответсвует условию = ""
if
(
!
(
null
===
matchingInfo
.
op
&&
""
===
matchingInfo
.
val
.
value
&&
0
===
arg1Matrix
[
i
][
j
].
value
)){
arg0Matrix
[
i
][
j
]
=
null
;
}
}
}
}
}
var
resArr
=
[];
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
)
{
resArr
.
push
(
valMatrix0
.
getValue
());
}
}
}
if
(
0
===
resArr
.
length
){
return
this
.
value
=
new
cNumber
(
0
);
}
resArr
.
sort
(
function
(
a
,
b
)
{
return
a
-
b
;
});
return
this
.
value
=
new
cNumber
(
resArr
[
0
]);
};
cMINIFS
.
prototype
.
checkArguments
=
function
()
{
return
1
===
this
.
argumentsCurrent
%
2
&&
cBaseFunction
.
prototype
.
checkArguments
.
apply
(
this
,
arguments
);
};
/**
/**
* @constructor
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
* @extends {AscCommonExcel.cBaseFunction}
...
...
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