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
702cfc43
Commit
702cfc43
authored
May 25, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add COT/COTH formulas
parent
6682d9ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
28 deletions
+131
-28
cell/model/FormulaObjects/_xlfnFunctions.js
cell/model/FormulaObjects/_xlfnFunctions.js
+1
-25
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+116
-1
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+14
-2
No files found.
cell/model/FormulaObjects/_xlfnFunctions.js
View file @
702cfc43
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
cFormulaFunctionGroup
[
'
Financial
'
].
push
(
cPDURATION
,
cRRI
);
cFormulaFunctionGroup
[
'
Financial
'
].
push
(
cPDURATION
,
cRRI
);
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cAGGREGATE
,
cBASE
,
cCEILING_MATH
,
cCEILING_PRECISE
,
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cAGGREGATE
,
cBASE
,
cCEILING_MATH
,
cCEILING_PRECISE
,
cCOMBINA
,
cC
OT
,
cCOTH
,
cC
SC
,
cCSCH
,
cDECIMAL
,
cFLOOR_MATH
,
cFLOOR_PRECISE
,
cMUNIT
,
cSEC
,
cSECH
);
cCOMBINA
,
cCSC
,
cCSCH
,
cDECIMAL
,
cFLOOR_MATH
,
cFLOOR_PRECISE
,
cMUNIT
,
cSEC
,
cSECH
);
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cFORMULATEXT
);
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cFORMULATEXT
);
cFormulaFunctionGroup
[
'
Information
'
]
=
cFormulaFunctionGroup
[
'
Information
'
]
||
[];
cFormulaFunctionGroup
[
'
Information
'
]
=
cFormulaFunctionGroup
[
'
Information
'
]
||
[];
...
@@ -341,30 +341,6 @@
...
@@ -341,30 +341,6 @@
cCONFIDENCE_T
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCONFIDENCE_T
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCONFIDENCE_T
.
prototype
.
constructor
=
cCONFIDENCE_T
;
cCONFIDENCE_T
.
prototype
.
constructor
=
cCONFIDENCE_T
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cCOT
()
{
cBaseFunction
.
call
(
this
,
"
COT
"
);
this
.
isXLFN
=
true
;
}
cCOT
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOT
.
prototype
.
constructor
=
cCOT
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cCOTH
()
{
cBaseFunction
.
call
(
this
,
"
COTH
"
);
this
.
isXLFN
=
true
;
}
cCOTH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOTH
.
prototype
.
constructor
=
cCOTH
;
/**
/**
* @constructor
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
* @extends {AscCommonExcel.cBaseFunction}
...
...
cell/model/FormulaObjects/mathematicFunctions.js
View file @
702cfc43
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cABS
,
cACOS
,
cACOSH
,
cACOT
,
cACOTH
,
cARABIC
,
cASIN
,
cASINH
,
cATAN
,
cATAN2
,
cATANH
,
cCEILING
,
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cABS
,
cACOS
,
cACOSH
,
cACOT
,
cACOTH
,
cARABIC
,
cASIN
,
cASINH
,
cATAN
,
cATAN2
,
cATANH
,
cCEILING
,
cCOMBIN
,
cCOS
,
cCOSH
,
cDEGREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cGCD
,
cINT
,
cCOMBIN
,
cCOS
,
cCOSH
,
c
COT
,
cCOTH
,
c
DEGREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cGCD
,
cINT
,
cISO_CEILING
,
cLCM
,
cLN
,
cLOG
,
cLOG10
,
cMDETERM
,
cMINVERSE
,
cMMULT
,
cMOD
,
cMROUND
,
cMULTINOMIAL
,
cODD
,
cPI
,
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
,
cSERIESSUM
,
cSIGN
,
cSIN
,
cSINH
,
cSQRT
,
cSQRTPI
,
cSUBTOTAL
,
cSUM
,
cSUMIF
,
cSUMIFS
,
cSUMPRODUCT
,
cSUMSQ
,
cSUMX2MY2
,
cSUMX2PY2
,
cSIGN
,
cSIN
,
cSINH
,
cSQRT
,
cSQRTPI
,
cSUBTOTAL
,
cSUM
,
cSUMIF
,
cSUMIFS
,
cSUMPRODUCT
,
cSUMSQ
,
cSUMX2MY2
,
cSUMX2PY2
,
...
@@ -890,6 +890,121 @@
...
@@ -890,6 +890,121 @@
};
};
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cCOT
()
{
this
.
name
=
"
COT
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cCOT
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOT
.
prototype
.
constructor
=
cCOT
;
cCOT
.
prototype
.
argumentsMin
=
1
;
cCOT
.
prototype
.
argumentsMax
=
1
;
cCOT
.
prototype
.
isXLFN
=
true
;
cCOT
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cCOT
.
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
(
0
===
elem
.
getValue
()){
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
division_by_zero
);
}
else
if
(
Math
.
abs
(
elem
.
getValue
())
>=
maxVal
)
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
{
var
a
=
1
/
Math
.
tan
(
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
(
0
===
arg0
.
getValue
()){
return
this
.
value
=
new
cError
(
cErrorType
.
division_by_zero
);
}
else
if
(
Math
.
abs
(
arg0
.
getValue
())
>=
maxVal
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
var
a
=
1
/
Math
.
tan
(
arg0
.
getValue
());
return
this
.
value
=
isNaN
(
a
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
a
);
}
};
cCOT
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( x )
"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cCOTH
()
{
this
.
name
=
"
COTH
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cCOTH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOTH
.
prototype
.
constructor
=
cCOTH
;
cCOTH
.
prototype
.
argumentsMin
=
1
;
cCOTH
.
prototype
.
argumentsMax
=
1
;
cCOTH
.
prototype
.
isXLFN
=
true
;
cCOTH
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cCOTH
.
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
)
{
if
(
0
===
elem
.
getValue
()){
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
division_by_zero
);
}
else
{
var
a
=
1
/
Math
.
tanh
(
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
(
0
===
arg0
.
getValue
()){
return
this
.
value
=
new
cError
(
cErrorType
.
division_by_zero
);
}
var
a
=
1
/
Math
.
tanh
(
arg0
.
getValue
());
return
this
.
value
=
isNaN
(
a
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
a
);
}
};
cCOTH
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( x )
"
};
};
/**
/**
* @constructor
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
* @extends {AscCommonExcel.cBaseFunction}
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
702cfc43
...
@@ -537,8 +537,20 @@ Math.cosh = function ( arg ) {
...
@@ -537,8 +537,20 @@ Math.cosh = function ( arg ) {
return
(
this
.
pow
(
this
.
E
,
arg
)
+
this
.
pow
(
this
.
E
,
-
arg
))
/
2
;
return
(
this
.
pow
(
this
.
E
,
arg
)
+
this
.
pow
(
this
.
E
,
-
arg
))
/
2
;
};
};
Math
.
tanh
=
function
(
arg
)
{
Math
.
tanh
=
Math
.
tanh
||
function
(
x
)
{
return
this
.
sinh
(
arg
)
/
this
.
cosh
(
arg
);
if
(
x
===
Infinity
)
{
return
1
;
}
else
if
(
x
===
-
Infinity
)
{
return
-
1
;
}
else
{
var
y
=
Math
.
exp
(
2
*
x
);
if
(
y
===
Infinity
)
{
return
1
;
}
else
if
(
y
===
-
Infinity
)
{
return
-
1
;
}
return
(
y
-
1
)
/
(
y
+
1
);
}
};
};
Math
.
asinh
=
function
(
arg
)
{
Math
.
asinh
=
function
(
arg
)
{
...
...
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