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
dc5046d2
Commit
dc5046d2
authored
May 26, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add SEC/SECH formulas
parent
99eb99c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
185 additions
and
26 deletions
+185
-26
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+82
-0
cell/model/FormulaObjects/_xlfnFunctions.js
cell/model/FormulaObjects/_xlfnFunctions.js
+1
-25
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+102
-1
No files found.
cell/.unit-tests/FormulaTests.js
View file @
dc5046d2
...
...
@@ -764,6 +764,88 @@ $( function () {
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#VALUE!
"
);
}
);
test
(
"
Test:
\"
SEC(45)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SEC(45)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
5
)
-
0
,
1.90359
);
}
);
test
(
"
Test:
\"
SEC(30)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SEC(30)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
5
)
-
0
,
6.48292
);
}
);
test
(
"
Test:
\"
SEC(0)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SEC(0)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
//> Math.pow(2, 27)
test
(
"
Test:
\"
SEC(1000000000)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SEC(1000000000)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#NUM!
"
);
}
);
//ABS > Math.pow(2, 27)
test
(
"
Test:
\"
CSC(-1000000000)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
CSC(-1000000000)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#NUM!
"
);
}
);
test
(
"
Test:
\"
SEC(test)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SEC(test)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#NAME?
"
);
}
);
test
(
"
Test:
\"
SEC('test')
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SEC("test")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#VALUE!
"
);
}
);
test
(
"
Test:
\"
SECH(5)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SECH(5)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
3
)
-
0
,
0.013
);
}
);
test
(
"
Test:
\"
SECH(0)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SECH(0)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
//> Math.pow(2, 27)
test
(
"
Test:
\"
SECH(1000000000)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SECH(1000000000)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
}
);
//ABS > Math.pow(2, 27)
test
(
"
Test:
\"
CSCH(-1000000000)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
CSCH(-1000000000)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
}
);
test
(
"
Test:
\"
SECH(test)
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SECH(test)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#NAME?
"
);
}
);
test
(
"
Test:
\"
SECH('test')
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
SECH("test")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#VALUE!
"
);
}
);
test
(
"
Test:
\"
ARABIC('LVII')
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
ARABIC("LVII")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
...
...
cell/model/FormulaObjects/_xlfnFunctions.js
View file @
dc5046d2
...
...
@@ -69,7 +69,7 @@
cFormulaFunctionGroup
[
'
Financial
'
].
push
(
cPDURATION
,
cRRI
);
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cAGGREGATE
,
cBASE
,
cCEILING_MATH
,
cCEILING_PRECISE
,
cCOMBINA
,
cDECIMAL
,
cFLOOR_MATH
,
cFLOOR_PRECISE
,
cMUNIT
,
cSEC
,
cSECH
);
cCOMBINA
,
cDECIMAL
,
cFLOOR_MATH
,
cFLOOR_PRECISE
,
cMUNIT
);
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cFORMULATEXT
);
cFormulaFunctionGroup
[
'
Information
'
]
=
cFormulaFunctionGroup
[
'
Information
'
]
||
[];
...
...
@@ -1109,30 +1109,6 @@
cRRI
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cRRI
.
prototype
.
constructor
=
cRRI
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cSEC
()
{
cBaseFunction
.
call
(
this
,
"
SEC
"
);
this
.
isXLFN
=
true
;
}
cSEC
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cSEC
.
prototype
.
constructor
=
cSEC
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cSECH
()
{
cBaseFunction
.
call
(
this
,
"
SECH
"
);
this
.
isXLFN
=
true
;
}
cSECH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cSECH
.
prototype
.
constructor
=
cSECH
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
cell/model/FormulaObjects/mathematicFunctions.js
View file @
dc5046d2
...
...
@@ -59,7 +59,7 @@
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cABS
,
cACOS
,
cACOSH
,
cACOT
,
cACOTH
,
cARABIC
,
cASIN
,
cASINH
,
cATAN
,
cATAN2
,
cATANH
,
cCEILING
,
cCOMBIN
,
cCOS
,
cCOSH
,
cCOT
,
cCOTH
,
cCSC
,
cCSCH
,
cDEGREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cGCD
,
cINT
,
cISO_CEILING
,
cLCM
,
cLN
,
cLOG
,
cLOG10
,
cMDETERM
,
cMINVERSE
,
cMMULT
,
cMOD
,
cMROUND
,
cMULTINOMIAL
,
cODD
,
cPI
,
cPOWER
,
cPRODUCT
,
cQUOTIENT
,
cRADIANS
,
cRAND
,
cRANDBETWEEN
,
cROMAN
,
cROUND
,
cROUNDDOWN
,
cROUNDUP
,
cSERIESSUM
,
cPOWER
,
cPRODUCT
,
cQUOTIENT
,
cRADIANS
,
cRAND
,
cRANDBETWEEN
,
cROMAN
,
cROUND
,
cROUNDDOWN
,
cROUNDUP
,
cSE
C
,
cSECH
,
cSE
RIESSUM
,
cSIGN
,
cSIN
,
cSINH
,
cSQRT
,
cSQRTPI
,
cSUBTOTAL
,
cSUM
,
cSUMIF
,
cSUMIFS
,
cSUMPRODUCT
,
cSUMSQ
,
cSUMX2MY2
,
cSUMX2PY2
,
cSUMXMY2
,
cTAN
,
cTANH
,
cTRUNC
);
...
...
@@ -3562,6 +3562,107 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cSEC
()
{
this
.
name
=
"
SEC
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cSEC
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cSEC
.
prototype
.
constructor
=
cSEC
;
cSEC
.
prototype
.
argumentsMin
=
1
;
cSEC
.
prototype
.
argumentsMax
=
1
;
cSEC
.
prototype
.
isXLFN
=
true
;
cSEC
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cSEC
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
var
maxVal
=
Math
.
pow
(
2
,
27
);
if
(
cElementType
.
cellsRange
===
arg0
.
type
||
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
]);
}
arg0
=
arg0
.
tocNumber
();
if
(
cElementType
.
error
===
arg0
.
type
)
{
return
this
.
value
=
arg0
;
}
else
if
(
cElementType
.
array
===
arg0
.
type
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
if
(
cElementType
.
number
===
elem
.
type
)
{
if
(
Math
.
abs
(
elem
.
getValue
())
>=
maxVal
)
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
{
var
a
=
1
/
Math
.
cos
(
elem
.
getValue
());
this
.
array
[
r
][
c
]
=
isNaN
(
a
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
a
);
}
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
{
if
(
Math
.
abs
(
arg0
.
getValue
())
>=
maxVal
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
var
a
=
1
/
Math
.
cos
(
arg0
.
getValue
());
return
this
.
value
=
isNaN
(
a
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
a
);
}
};
cSEC
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( x )
"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cSECH
()
{
this
.
name
=
"
SECH
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cSECH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cSECH
.
prototype
.
constructor
=
cSECH
;
cSECH
.
prototype
.
argumentsMin
=
1
;
cSECH
.
prototype
.
argumentsMax
=
1
;
cSECH
.
prototype
.
isXLFN
=
true
;
cSECH
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cSECH
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
//TODO в документации к COTH написано максимальное значение - Math.pow(2, 27), но MS EXCEL в данном случае не выдает ошибку
//проверку на максиимальное значение убрал
if
(
cElementType
.
cellsRange
===
arg0
.
type
||
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
]);
}
arg0
=
arg0
.
tocNumber
();
if
(
cElementType
.
error
===
arg0
.
type
)
{
return
this
.
value
=
arg0
;
}
else
if
(
cElementType
.
array
===
arg0
.
type
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
if
(
cElementType
.
number
===
elem
.
type
)
{
var
a
=
1
/
Math
.
cosh
(
elem
.
getValue
());
this
.
array
[
r
][
c
]
=
isNaN
(
a
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
a
);
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
{
var
a
=
1
/
Math
.
cosh
(
arg0
.
getValue
());
return
this
.
value
=
isNaN
(
a
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
a
);
}
};
cSECH
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( x )
"
};
};
/**
* @constructor
* @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