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
26f7b13c
Commit
26f7b13c
authored
May 31, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add DECIMAL formula
parent
fee02096
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
17 deletions
+88
-17
cell/model/FormulaObjects/_xlfnFunctions.js
cell/model/FormulaObjects/_xlfnFunctions.js
+1
-13
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+84
-1
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+3
-3
No files found.
cell/model/FormulaObjects/_xlfnFunctions.js
View file @
26f7b13c
...
...
@@ -68,7 +68,7 @@
cFormulaFunctionGroup
[
'
Financial
'
]
=
cFormulaFunctionGroup
[
'
Financial
'
]
||
[];
cFormulaFunctionGroup
[
'
Financial
'
].
push
(
cPDURATION
,
cRRI
);
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cAGGREGATE
,
cBASE
,
c
DECIMAL
,
c
MUNIT
);
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cAGGREGATE
,
cBASE
,
cMUNIT
);
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cFORMULATEXT
);
cFormulaFunctionGroup
[
'
Information
'
]
=
cFormulaFunctionGroup
[
'
Information
'
]
||
[];
...
...
@@ -364,18 +364,6 @@
cDBCS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cDBCS
.
prototype
.
constructor
=
cDBCS
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cDECIMAL
()
{
cBaseFunction
.
call
(
this
,
"
DECIMAL
"
);
this
.
isXLFN
=
true
;
}
cDECIMAL
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cDECIMAL
.
prototype
.
constructor
=
cDECIMAL
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
cell/model/FormulaObjects/mathematicFunctions.js
View file @
26f7b13c
...
...
@@ -57,7 +57,7 @@
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cABS
,
cACOS
,
cACOSH
,
cACOT
,
cACOTH
,
cARABIC
,
cASIN
,
cASINH
,
cATAN
,
cATAN2
,
cATANH
,
cCEILING
,
cCEILING_MATH
,
cCEILING_PRECISE
,
cCOMBIN
,
cCOMBINA
,
cCOS
,
cCOSH
,
cCOT
,
cCOTH
,
cCSC
,
cCSCH
,
cDEGREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cFLOOR_PRECISE
,
cFLOOR_MATH
,
cGCD
,
cINT
,
cCOMBIN
,
cCOMBINA
,
cCOS
,
cCOSH
,
cCOT
,
cCOTH
,
cCSC
,
cCSCH
,
cDE
CIMAL
,
cDE
GREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cFLOOR_PRECISE
,
cFLOOR_MATH
,
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
,
cSEC
,
cSECH
,
cSERIESSUM
,
cSIGN
,
cSIN
,
cSINH
,
cSQRT
,
cSQRTPI
,
cSUBTOTAL
,
cSUM
,
cSUMIF
,
cSUMIFS
,
cSUMPRODUCT
,
cSUMSQ
,
cSUMX2MY2
,
cSUMX2PY2
,
...
...
@@ -1276,6 +1276,89 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cDECIMAL
()
{
this
.
name
=
"
DECIMAL
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cDECIMAL
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cDECIMAL
.
prototype
.
constructor
=
cDECIMAL
;
cDECIMAL
.
prototype
.
argumentsMin
=
2
;
cDECIMAL
.
prototype
.
argumentsMax
=
2
;
cDECIMAL
.
prototype
.
isXLFN
=
true
;
cDECIMAL
.
prototype
.
Calculate
=
function
(
arg
)
{
var
argClone
=
[];
argClone
[
0
]
=
this
.
_checkCAreaArg
(
arg
[
0
],
arguments
[
1
]);
argClone
[
1
]
=
this
.
_checkCAreaArg
(
arg
[
1
],
arguments
[
1
]);
argClone
[
0
]
=
argClone
[
0
].
tocString
();
argClone
[
1
]
=
argClone
[
1
].
tocNumber
();
var
argError
;
if
(
false
!==
(
argError
=
this
.
_checkErrorArg
(
argClone
))){
return
this
.
value
=
argError
;
}
function
decimal_calculate
(
argArray
){
var
a
=
argArray
[
0
];
var
b
=
argArray
[
1
];
b
=
parseInt
(
b
);
if
(
b
<
2
||
b
>
36
)
{
return
new
cError
(
cErrorType
.
not_numeric
);
}
var
fVal
=
0
;
var
startIndex
=
0
;
while
(
a
[
startIndex
]
===
'
'
){
startIndex
++
;
}
if
(
b
===
16
){
if
(
a
[
startIndex
]
===
'
x
'
||
a
[
startIndex
]
===
'
X
'
){
startIndex
++
;
}
else
if
(
a
[
startIndex
]
===
'
0
'
&&
(
a
[
startIndex
+
1
]
===
'
x
'
||
a
[
startIndex
+
1
]
===
'
X
'
)
){
startIndex
+=
2
;
}
}
a
=
a
.
toLowerCase
();
var
startPos
=
'
a
'
.
charCodeAt
(
0
);
for
(
var
i
=
startIndex
;
i
<
a
.
length
;
i
++
){
var
n
;
if
(
'
0
'
<=
a
[
i
]
&&
a
[
i
]
<=
'
9
'
){
n
=
a
[
i
]
-
'
0
'
;
}
else
if
(
'
a
'
<=
a
[
i
]
&&
a
[
i
]
<=
'
z
'
){
var
currentPos
=
a
[
i
].
charCodeAt
(
0
);
n
=
10
+
parseInt
(
currentPos
-
startPos
);
}
else
{
n
=
b
;
}
if
(
b
<=
n
){
return
new
cError
(
cErrorType
.
not_numeric
);
}
else
{
fVal
=
fVal
*
b
+
n
;
}
}
return
isNaN
(
fVal
)
?
new
cError
(
cErrorType
.
not_numeric
)
:
new
cNumber
(
fVal
);
}
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
argClone
,
decimal_calculate
,
true
);
};
cDECIMAL
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( number , number-chosen )
"
};
};
/**
* @constructor
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
26f7b13c
...
...
@@ -2369,7 +2369,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseFunction
.
prototype
.
checkArguments
=
function
()
{
return
this
.
argumentsMin
<=
this
.
argumentsCurrent
&&
this
.
argumentsCurrent
<=
this
.
argumentsMax
;
};
cBaseFunction
.
prototype
.
_findArrayInNumberArguments
=
function
(
inputArguments
,
calculateFunc
){
cBaseFunction
.
prototype
.
_findArrayInNumberArguments
=
function
(
inputArguments
,
calculateFunc
,
dNotCheckNumberType
){
var
argsArray
=
[];
for
(
var
i
=
0
;
i
<
inputArguments
.
length
;
i
++
){
if
(
cElementType
.
array
===
inputArguments
[
i
].
type
){
...
...
@@ -2386,7 +2386,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
arg
=
inputArguments
[
j
];
}
if
(
arg
&&
cElementType
.
number
===
arg
.
type
){
if
(
arg
&&
((
dNotCheckNumberType
)
||
(
cElementType
.
number
===
arg
.
type
&&
!
dNotCheckNumberType
))
){
argsArray
[
j
]
=
arg
.
getValue
();
}
else
{
argsArray
=
null
;
...
...
@@ -2398,7 +2398,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
});
return
inputArguments
[
i
];
}
else
{
if
(
cElementType
.
string
===
inputArguments
[
i
].
type
){
if
(
cElementType
.
string
===
inputArguments
[
i
].
type
&&
!
dNotCheckNumberType
){
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
else
{
argsArray
[
i
]
=
inputArguments
[
i
].
getValue
();
...
...
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