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
366abd36
Commit
366abd36
authored
Jun 16, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new calculation of functions VLOOKUP and HLOOKUP
new VHLOOKUPCache
parent
eb49d984
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1407 additions
and
1663 deletions
+1407
-1663
cell/model/FormulaObjects/lookupandreferenceFunctions.js
cell/model/FormulaObjects/lookupandreferenceFunctions.js
+1407
-1663
No files found.
cell/model/FormulaObjects/lookupandreferenceFunctions.js
View file @
366abd36
"
use strict
"
;
"
use strict
"
;
(
(
/**
/**
* @param {Window} window
* @param {Window} window
* @param {undefined} undefined
* @param {undefined} undefined
*/
*/
function
(
window
,
undefined
)
{
function
(
window
,
undefined
)
{
function
_getRowTitle
(
row
)
{
function
_getRowTitle
(
row
)
{
return
""
+
(
row
+
1
);
return
""
+
(
row
+
1
);
}
}
...
@@ -32,31 +31,14 @@ function (window, undefined) {
...
@@ -32,31 +31,14 @@ function (window, undefined) {
var
cBaseFunction
=
AscCommonExcel
.
cBaseFunction
;
var
cBaseFunction
=
AscCommonExcel
.
cBaseFunction
;
var
checkTypeCell
=
AscCommonExcel
.
checkTypeCell
;
var
checkTypeCell
=
AscCommonExcel
.
checkTypeCell
;
var
checkTypeCell2
=
AscCommonExcel
.
checkTypeCell2
;
var
cFormulaFunctionGroup
=
AscCommonExcel
.
cFormulaFunctionGroup
;
var
cFormulaFunctionGroup
=
AscCommonExcel
.
cFormulaFunctionGroup
;
var
_func
=
AscCommonExcel
.
_func
;
var
_func
=
AscCommonExcel
.
_func
;
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cADDRESS
,
cAREAS
,
cCHOOSE
,
cCOLUMN
,
cCOLUMNS
,
cGETPIVOTDATA
,
cADDRESS
,
cHLOOKUP
,
cHYPERLINK
,
cINDEX
,
cINDIRECT
,
cLOOKUP
,
cMATCH
,
cOFFSET
,
cROW
,
cROWS
,
cRTD
,
cTRANSPOSE
,
cVLOOKUP
);
cAREAS
,
cCHOOSE
,
cCOLUMN
,
cCOLUMNS
,
cGETPIVOTDATA
,
cHLOOKUP
,
cHYPERLINK
,
cINDEX
,
cINDIRECT
,
cLOOKUP
,
cMATCH
,
cOFFSET
,
cROW
,
cROWS
,
cRTD
,
cTRANSPOSE
,
cVLOOKUP
);
function
searchRegExp
(
str
,
flags
)
{
function
searchRegExp
(
str
,
flags
)
{
var
vFS
=
str
var
vFS
=
str
...
@@ -70,10 +52,10 @@ function (window, undefined) {
...
@@ -70,10 +52,10 @@ function (window, undefined) {
.
replace
(
/
(\{)
/g
,
"
\\
{
"
)
.
replace
(
/
(\{)
/g
,
"
\\
{
"
)
.
replace
(
/
(\})
/g
,
"
\\
}
"
)
.
replace
(
/
(\})
/g
,
"
\\
}
"
)
.
replace
(
/
(\$)
/g
,
"
\\
$
"
)
.
replace
(
/
(\$)
/g
,
"
\\
$
"
)
.
replace
(
/
(
~
)?\*
/g
,
function
(
$0
,
$1
)
{
.
replace
(
/
(
~
)?\*
/g
,
function
(
$0
,
$1
)
{
return
$1
?
$0
:
'
(.*)
'
;
return
$1
?
$0
:
'
(.*)
'
;
})
})
.
replace
(
/
(
~
)?\?
/g
,
function
(
$0
,
$1
)
{
.
replace
(
/
(
~
)?\?
/g
,
function
(
$0
,
$1
)
{
return
$1
?
$0
:
'
.{1}
'
;
return
$1
?
$0
:
'
.{1}
'
;
})
})
.
replace
(
/
(
~
\*)
/g
,
"
\\
*
"
).
replace
(
/
(
~
\?)
/g
,
"
\\
?
"
);
.
replace
(
/
(
~
\*)
/g
,
"
\\
*
"
).
replace
(
/
(
~
\?)
/g
,
"
\\
?
"
);
...
@@ -81,11 +63,8 @@ function (window, undefined) {
...
@@ -81,11 +63,8 @@ function (window, undefined) {
return
new
RegExp
(
vFS
+
"
$
"
,
flags
?
flags
:
"
i
"
);
return
new
RegExp
(
vFS
+
"
$
"
,
flags
?
flags
:
"
i
"
);
}
}
function
cADDRESS
()
{
/** @constructor */
// cBaseFunction.call( this, "ADDRESS" );
function
cADDRESS
()
{
// this.setArgumentsMin( 2 );
// this.setArgumentsMax( 5 );
this
.
name
=
"
ADDRESS
"
;
this
.
name
=
"
ADDRESS
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -93,54 +72,46 @@ function cADDRESS() {
...
@@ -93,54 +72,46 @@ function cADDRESS() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
5
;
this
.
argumentsMax
=
5
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cADDRESS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cADDRESS
.
prototype
.
Calculate
=
function
(
arg
)
{
cADDRESS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cADDRESS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
rowNumber
=
arg
[
0
],
colNumber
=
arg
[
1
],
var
rowNumber
=
arg
[
0
],
colNumber
=
arg
[
1
],
refType
=
arg
[
2
]
?
arg
[
2
]
:
new
cNumber
(
1
),
A1RefType
=
arg
[
3
]
?
refType
=
arg
[
2
]
?
arg
[
2
]
:
new
cNumber
(
1
),
arg
[
3
]
:
new
cBool
(
true
),
sheetName
=
arg
[
4
]
?
arg
[
4
]
:
new
cEmpty
();
A1RefType
=
arg
[
3
]
?
arg
[
3
]
:
new
cBool
(
true
),
sheetName
=
arg
[
4
]
?
arg
[
4
]
:
new
cEmpty
();
if
(
rowNumber
instanceof
cArea
||
rowNumber
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
rowNumber
.
type
||
cElementType
.
cellsRange3D
===
rowNumber
.
type
)
{
rowNumber
=
rowNumber
.
cross
(
arguments
[
1
].
first
);
rowNumber
=
rowNumber
.
cross
(
arguments
[
1
].
first
);
}
}
else
if
(
cElementType
.
array
===
rowNumber
.
type
)
{
else
if
(
rowNumber
instanceof
cArray
)
{
rowNumber
=
rowNumber
.
getElementRowCol
(
0
,
0
);
rowNumber
=
rowNumber
.
getElementRowCol
(
0
,
0
);
}
}
if
(
colNumber
instanceof
cArea
||
colNumber
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
colNumber
.
type
||
cElementType
.
cellsRange3D
===
colNumber
.
type
)
{
colNumber
=
colNumber
.
cross
(
arguments
[
1
].
first
);
colNumber
=
colNumber
.
cross
(
arguments
[
1
].
first
);
}
}
else
if
(
cElementType
.
array
===
colNumber
.
type
)
{
else
if
(
colNumber
instanceof
cArray
)
{
colNumber
=
colNumber
.
getElementRowCol
(
0
,
0
);
colNumber
=
colNumber
.
getElementRowCol
(
0
,
0
);
}
}
if
(
refType
instanceof
cArea
||
refType
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
refType
.
type
||
cElementType
.
cellsRange3D
===
refType
.
type
)
{
refType
=
refType
.
cross
(
arguments
[
1
].
first
);
refType
=
refType
.
cross
(
arguments
[
1
].
first
);
}
}
else
if
(
cElementType
.
array
===
refType
.
type
)
{
else
if
(
refType
instanceof
cArray
)
{
refType
=
refType
.
getElementRowCol
(
0
,
0
);
refType
=
refType
.
getElementRowCol
(
0
,
0
);
}
}
if
(
A1RefType
instanceof
cArea
||
A1RefType
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
A1RefType
.
type
||
cElementType
.
cellsRange3D
===
A1RefType
.
type
)
{
A1RefType
=
A1RefType
.
cross
(
arguments
[
1
].
first
);
A1RefType
=
A1RefType
.
cross
(
arguments
[
1
].
first
);
}
}
else
if
(
cElementType
.
array
===
A1RefType
.
type
)
{
else
if
(
A1RefType
instanceof
cArray
)
{
A1RefType
=
A1RefType
.
getElementRowCol
(
0
,
0
);
A1RefType
=
A1RefType
.
getElementRowCol
(
0
,
0
);
}
}
if
(
sheetName
instanceof
cArea
||
sheetName
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
sheetName
.
type
||
cElementType
.
cellsRange3D
===
sheetName
.
type
)
{
sheetName
=
sheetName
.
cross
(
arguments
[
1
].
first
);
sheetName
=
sheetName
.
cross
(
arguments
[
1
].
first
);
}
}
else
if
(
cElementType
.
array
===
sheetName
.
type
)
{
else
if
(
sheetName
instanceof
cArray
)
{
sheetName
=
sheetName
.
getElementRowCol
(
0
,
0
);
sheetName
=
sheetName
.
getElementRowCol
(
0
,
0
);
}
}
rowNumber
=
rowNumber
.
tocNumber
();
rowNumber
=
rowNumber
.
tocNumber
();
...
@@ -148,57 +119,66 @@ cADDRESS.prototype.Calculate = function ( arg ) {
...
@@ -148,57 +119,66 @@ cADDRESS.prototype.Calculate = function ( arg ) {
refType
=
refType
.
tocNumber
();
refType
=
refType
.
tocNumber
();
A1RefType
=
A1RefType
.
tocBool
();
A1RefType
=
A1RefType
.
tocBool
();
if
(
rowNumber
instanceof
cError
)
return
this
.
value
=
rowNumber
;
if
(
cElementType
.
error
===
rowNumber
.
type
)
{
if
(
colNumber
instanceof
cError
)
return
this
.
value
=
colNumber
;
return
this
.
value
=
rowNumber
;
if
(
refType
instanceof
cError
)
return
this
.
value
=
refType
;
}
if
(
A1RefType
instanceof
cError
)
return
this
.
value
=
A1RefType
;
if
(
cElementType
.
error
===
colNumber
.
type
)
{
if
(
sheetName
instanceof
cError
)
return
this
.
value
=
sheetName
;
return
this
.
value
=
colNumber
;
}
if
(
cElementType
.
error
===
refType
.
type
)
{
return
this
.
value
=
refType
;
}
if
(
cElementType
.
error
===
A1RefType
.
type
)
{
return
this
.
value
=
A1RefType
;
}
if
(
cElementType
.
error
===
sheetName
.
type
)
{
return
this
.
value
=
sheetName
;
}
rowNumber
=
rowNumber
.
getValue
();
rowNumber
=
rowNumber
.
getValue
();
colNumber
=
colNumber
.
getValue
();
colNumber
=
colNumber
.
getValue
();
refType
=
refType
.
getValue
();
refType
=
refType
.
getValue
();
A1RefType
=
A1RefType
.
getValue
();
A1RefType
=
A1RefType
.
getValue
();
if
(
refType
>
4
||
refType
<
1
||
rowNumber
<
1
||
rowNumber
>
AscCommon
.
gc_nMaxRow
||
colNumber
<
1
||
colNumber
>
AscCommon
.
gc_nMaxCol
)
{
if
(
refType
>
4
||
refType
<
1
||
rowNumber
<
1
||
rowNumber
>
AscCommon
.
gc_nMaxRow
||
colNumber
<
1
||
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
colNumber
>
AscCommon
.
gc_nMaxCol
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
var
strRef
;
var
strRef
;
switch
(
refType
)
{
switch
(
refType
)
{
case
1
:
case
1
:
strRef
=
"
$
"
+
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
"
$
"
+
rowNumber
;
strRef
=
"
$
"
+
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
"
$
"
+
rowNumber
;
break
;
break
;
case
2
:
case
2
:
strRef
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
"
$
"
+
rowNumber
;
strRef
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
"
$
"
+
rowNumber
;
break
;
break
;
case
3
:
case
3
:
strRef
=
"
$
"
+
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
rowNumber
;
strRef
=
"
$
"
+
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
rowNumber
;
break
;
break
;
case
4
:
case
4
:
strRef
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
rowNumber
;
strRef
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
colNumber
)
+
rowNumber
;
break
;
break
;
}
}
return
this
.
value
=
new
cString
(
(
sheetName
instanceof
cEmpty
)
?
strRef
:
return
this
.
value
=
parserHelp
.
get3DRef
(
sheetName
.
toString
(),
strRef
)
);
new
cString
((
cElementType
.
empty
===
sheetName
.
type
)
?
strRef
:
parserHelp
.
get3DRef
(
sheetName
.
toString
(),
strRef
)
);
};
};
cADDRESS
.
prototype
.
getInfo
=
function
()
{
cADDRESS
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( row-number , col-number [ , [ ref-type ] [ , [ A1-ref-style-flag ] [ , sheet-name ] ] ] )
"
args
:
"
( row-number , col-number [ , [ ref-type ] [ , [ A1-ref-style-flag ] [ , sheet-name ] ] ] )
"
};
};
};
};
function
cAREAS
()
{
cBaseFunction
.
call
(
this
,
"
AREAS
"
);
}
cAREAS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
/** @constructor */
function
cAREAS
()
{
cBaseFunction
.
call
(
this
,
"
AREAS
"
);
}
function
cCHOOSE
()
{
cAREAS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
// cBaseFunction.call( this, "CHOOSE" );
// this.setArgumentsMin( 2 );
// this.setArgumentsMax( 30 );
/** @constructor */
function
cCHOOSE
()
{
this
.
name
=
"
CHOOSE
"
;
this
.
name
=
"
CHOOSE
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -206,48 +186,43 @@ function cCHOOSE() {
...
@@ -206,48 +186,43 @@ function cCHOOSE() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
30
;
this
.
argumentsMax
=
30
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cCHOOSE
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCHOOSE
.
prototype
.
Calculate
=
function
(
arg
)
{
cCHOOSE
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCHOOSE
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
var
arg0
=
arg
[
0
];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
arg0
.
type
||
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
].
first
);
arg0
=
arg0
.
cross
(
arguments
[
1
].
first
);
}
}
arg0
=
arg0
.
tocNumber
();
arg0
=
arg0
.
tocNumber
();
if
(
arg0
instanceof
cError
)
{
if
(
cElementType
.
error
===
arg0
.
type
)
{
return
this
.
value
=
arg0
;
return
this
.
value
=
arg0
;
}
}
if
(
arg0
instanceof
cNumber
)
{
if
(
cElementType
.
number
===
arg0
.
type
)
{
if
(
arg0
.
getValue
()
<
1
||
arg0
.
getValue
()
>
this
.
getArguments
()
-
1
)
{
if
(
arg0
.
getValue
()
<
1
||
arg0
.
getValue
()
>
this
.
getArguments
()
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
return
this
.
value
=
arg
[
Math
.
floor
(
arg0
.
getValue
())];
return
this
.
value
=
arg
[
Math
.
floor
(
arg0
.
getValue
())];
}
}
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
};
};
cCHOOSE
.
prototype
.
getInfo
=
function
()
{
cCHOOSE
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( index , argument-list )
"
args
:
"
( index , argument-list )
"
};
};
};
};
function
cCOLUMN
()
{
// cBaseFunction.call( this, "COLUMN" );
// this.setArgumentsMin( 0 );
// this.setArgumentsMax( 1 );
/** @constructor */
function
cCOLUMN
()
{
this
.
name
=
"
COLUMN
"
;
this
.
name
=
"
COLUMN
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -255,52 +230,46 @@ function cCOLUMN() {
...
@@ -255,52 +230,46 @@ function cCOLUMN() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
1
;
this
.
argumentsMax
=
1
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cCOLUMN
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOLUMN
.
prototype
.
Calculate
=
function
(
arg
)
{
cCOLUMN
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOLUMN
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
;
var
arg0
;
if
(
this
.
argumentsCurrent
==
0
)
{
if
(
this
.
argumentsCurrent
==
0
)
{
arg0
=
arguments
[
1
];
arg0
=
arguments
[
1
];
return
this
.
value
=
new
cNumber
(
arg0
.
getFirst
().
getCol
()
);
return
this
.
value
=
new
cNumber
(
arg0
.
getFirst
().
getCol
()
);
}
}
arg0
=
arg
[
0
];
arg0
=
arg
[
0
];
if
(
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
||
arg0
instanceof
cArea
)
{
if
(
cElementType
.
cell
===
arg0
.
type
||
cElementType
.
cell3D
===
arg0
.
type
||
cElementType
.
cellsRange
===
arg0
.
type
)
{
var
range
=
arg0
.
getRange
();
var
range
=
arg0
.
getRange
();
if
(
range
)
if
(
range
)
{
return
this
.
value
=
new
cNumber
(
range
.
getFirst
().
getCol
()
);
return
this
.
value
=
new
cNumber
(
range
.
getFirst
().
getCol
()
);
else
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
if
(
arg0
instanceof
cArea3D
)
{
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
var
r
=
arg0
.
getRange
();
var
r
=
arg0
.
getRange
();
if
(
r
&&
r
[
0
]
&&
r
[
0
].
getFirst
()
)
{
if
(
r
&&
r
[
0
]
&&
r
[
0
].
getFirst
())
{
return
this
.
value
=
new
cNumber
(
r
[
0
].
getFirst
().
getCol
()
);
return
this
.
value
=
new
cNumber
(
r
[
0
].
getFirst
().
getCol
());
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
{
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
}
};
else
cCOLUMN
.
prototype
.
getInfo
=
function
()
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
};
cCOLUMN
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( [ reference ] )
"
args
:
"
( [ reference ] )
"
};
};
};
};
function
cCOLUMNS
()
{
// cBaseFunction.call( this, "COLUMNS" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 1 );
/** @constructor */
function
cCOLUMNS
()
{
this
.
name
=
"
COLUMNS
"
;
this
.
name
=
"
COLUMNS
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -308,51 +277,47 @@ function cCOLUMNS() {
...
@@ -308,51 +277,47 @@ function cCOLUMNS() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
1
;
this
.
argumentsMax
=
1
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cCOLUMNS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOLUMNS
.
prototype
.
Calculate
=
function
(
arg
)
{
cCOLUMNS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOLUMNS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
var
arg0
=
arg
[
0
];
if
(
arg0
instanceof
cArray
)
{
if
(
cElementType
.
array
===
arg0
.
type
)
{
return
this
.
value
=
new
cNumber
(
arg0
.
getCountElementInRow
()
);
return
this
.
value
=
new
cNumber
(
arg0
.
getCountElementInRow
()
);
}
}
else
if
(
cElementType
.
cellsRange
===
arg0
.
type
||
cElementType
.
cell
===
arg0
.
type
||
else
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
)
{
cElementType
.
cell3D
===
arg0
.
type
)
{
var
range
=
arg0
.
getRange
();
var
range
=
arg0
.
getRange
();
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
.
getBBox
().
c1
-
range
.
getBBox
().
c2
)
+
1
);
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
.
getBBox
().
c1
-
range
.
getBBox
().
c2
)
+
1
);
}
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
else
if
(
arg0
instanceof
cArea3D
)
{
var
range
=
arg0
.
getRange
();
var
range
=
arg0
.
getRange
();
if
(
range
.
length
>
1
)
if
(
range
.
length
>
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
[
0
].
getBBox
().
c1
-
range
[
0
].
getBBox
().
c2
)
+
1
);
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
[
0
].
getBBox
().
c1
-
range
[
0
].
getBBox
().
c2
)
+
1
);
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
else
};
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
cCOLUMNS
.
prototype
.
getInfo
=
function
()
{
};
cCOLUMNS
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( array )
"
args
:
"
( array )
"
};
};
};
};
function
cGETPIVOTDATA
()
{
cBaseFunction
.
call
(
this
,
"
GETPIVOTDATA
"
);
}
cGETPIVOTDATA
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
/** @constructor */
function
cGETPIVOTDATA
()
{
cBaseFunction
.
call
(
this
,
"
GETPIVOTDATA
"
);
}
function
cHLOOKUP
()
{
cGETPIVOTDATA
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
// cBaseFunction.call( this, "HLOOKUP" );
// this.setArgumentsMin( 3 );
// this.setArgumentsMax( 4 );
/** @constructor */
function
cHLOOKUP
()
{
this
.
name
=
"
HLOOKUP
"
;
this
.
name
=
"
HLOOKUP
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -360,142 +325,121 @@ function cHLOOKUP() {
...
@@ -360,142 +325,121 @@ function cHLOOKUP() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
4
;
this
.
argumentsMax
=
4
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cHLOOKUP
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cHLOOKUP
.
prototype
.
Calculate
=
function
(
arg
)
{
cHLOOKUP
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
cHLOOKUP
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg3
=
this
.
argumentsCurrent
==
4
?
arg
[
3
].
tocBool
().
value
:
true
;
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
],
arg3
=
this
.
argumentsCurrent
==
4
?
arg
[
3
].
tocBool
()
:
new
cBool
(
true
);
var
numberRow
=
arg2
.
getValue
()
-
1
,
valueForSearching
=
arg0
.
getValue
(),
resC
=
-
1
,
min
,
regexp
;
var
numberRow
=
arg2
.
getValue
()
-
1
,
valueForSearching
=
arg0
.
getValue
(),
resC
=
-
1
,
min
,
regexp
;
if
(
isNaN
(
numberRow
)
)
if
(
isNaN
(
numberRow
))
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
if
(
numberRow
<
0
)
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
if
(
arg0
instanceof
cString
)
{
valueForSearching
=
arg0
.
getValue
();
regexp
=
searchRegExp
(
valueForSearching
);
}
}
else
if
(
arg0
instanceof
cError
)
if
(
numberRow
<
0
)
{
return
this
.
value
=
arg0
;
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
else
{
valueForSearching
=
arg0
.
getValue
();
}
}
var
found
=
false
,
bb
;
if
(
cElementType
.
cell3D
===
arg0
.
type
||
cElementType
.
cell
===
arg0
.
type
)
{
arg0
=
arg0
.
getValue
();
if
(
arg1
instanceof
cRef
||
arg1
instanceof
cRef3D
||
arg1
instanceof
cArea
)
{
var
range
=
arg1
.
getRange
(),
ws
=
arg1
.
getWS
();
bb
=
range
.
getBBox0
();
if
(
numberRow
>
bb
.
r2
-
bb
.
r1
)
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r1
,
bb
.
c2
);
var
oCache
=
g_oHLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg0
instanceof
cString
,
arg3
.
value
);
if
(
oCache
)
{
resC
=
oCache
.
index
;
min
=
oCache
.
min
;
}
// range._foreachColNoEmpty( /*func for col*/ null, /*func for cell in col*/ f );
}
}
else
if
(
arg1
instanceof
cArea3D
)
{
var
range
=
arg1
.
getRange
()[
0
],
ws
=
arg1
.
getWS
();
bb
=
range
.
getBBox0
();
if
(
numberRow
>
bb
.
r2
-
bb
.
r1
)
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r1
,
bb
.
c2
);
if
(
cElementType
.
string
===
arg0
.
type
)
{
var
oCache
=
g_oHLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg0
instanceof
cString
,
arg3
.
value
);
valueForSearching
=
arg0
.
getValue
();
if
(
oCache
)
{
regexp
=
searchRegExp
(
valueForSearching
);
resC
=
oCache
.
index
;
}
else
if
(
cElementType
.
error
===
arg0
.
type
)
{
min
=
oCache
.
min
;
return
this
.
value
=
arg0
;
}
else
{
valueForSearching
=
arg0
.
getValue
();
}
}
// range._foreachColNoEmpty( /*func for col*/ null, /*func for cell in col*/ f );
var
found
=
false
;
}
if
(
cElementType
.
array
===
arg1
.
type
)
{
else
if
(
arg1
instanceof
cArray
)
{
arg1
.
foreach
(
function
(
elem
,
r
,
c
)
{
arg1
.
foreach
(
function
(
elem
,
r
,
c
)
{
if
(
c
==
0
)
{
if
(
c
==
0
)
min
=
elem
.
getValue
();
min
=
elem
.
getValue
();
}
if
(
arg3
.
value
==
true
)
{
if
(
arg3
===
true
)
{
if
(
valueForSearching
==
elem
.
getValue
()
)
{
if
(
valueForSearching
==
elem
.
getValue
()
)
{
resC
=
c
;
resC
=
c
;
found
=
true
;
found
=
true
;
}
}
else
if
(
valueForSearching
>
elem
.
getValue
()
&&
!
found
)
{
else
if
(
valueForSearching
>
elem
.
getValue
()
&&
!
found
)
{
resC
=
c
;
resC
=
c
;
}
}
}
}
else
{
else
{
if
(
cElementType
.
string
===
arg0
.
type
)
{
if
(
arg0
instanceof
cString
)
{
if
(
regexp
.
test
(
elem
.
getValue
()))
{
if
(
regexp
.
test
(
elem
.
getValue
()
)
)
resC
=
c
;
resC
=
c
;
}
}
else
if
(
valueForSearching
==
elem
.
getValue
()
)
{
}
else
if
(
valueForSearching
==
elem
.
getValue
()
)
{
resC
=
c
;
resC
=
c
;
}
}
}
}
min
=
Math
.
min
(
min
,
elem
.
getValue
()
);
min
=
Math
.
min
(
min
,
elem
.
getValue
()
);
}
);
}
);
if
(
min
>
valueForSearching
)
{
if
(
min
>
valueForSearching
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
if
(
resC
==
-
1
)
{
if
(
resC
==
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
if
(
numberRow
>
arg1
.
getRowCount
()
-
1
)
{
if
(
numberRow
>
arg1
.
getRowCount
()
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
return
this
.
value
=
arg1
.
getElementRowCol
(
numberRow
,
resC
);
return
this
.
value
=
arg1
.
getElementRowCol
(
numberRow
,
resC
);
}
}
if
(
min
>
valueForSearching
)
{
var
range
;
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
if
(
cElementType
.
cell
===
arg1
.
type
||
cElementType
.
cell3D
===
arg1
.
type
||
cElementType
.
cellsRange
===
arg1
.
type
)
{
range
=
arg1
.
getRange
();
}
else
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
)
{
range
=
arg1
.
getRange
()[
0
];
}
}
if
(
!
range
)
{
if
(
resC
==
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
var
c
=
new
CellAddress
(
bb
.
r1
+
numberRow
,
resC
,
0
);
var
bb
=
range
.
getBBox0
();
if
(
numberRow
>
bb
.
r2
-
bb
.
r1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
var
ws
=
arg1
.
getWS
();
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r1
,
bb
.
c2
);
var
v
=
arg1
.
getWS
().
_getCellNoEmpty
(
c
.
getRow0
(),
c
.
getCol0
()
);
resC
=
g_oHLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg3
);
if
(
v
)
if
(
-
1
===
resC
)
{
v
=
v
.
getValueWithoutFormat
();
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
else
}
v
=
""
;
return
this
.
value
=
checkTypeCell
(
v
);
var
v
=
arg1
.
getWS
().
_getCellNoEmpty
(
bb
.
r1
+
numberRow
,
resC
);
};
return
this
.
value
=
checkTypeCell2
(
v
);
cHLOOKUP
.
prototype
.
getInfo
=
function
()
{
};
cHLOOKUP
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( lookup-value , table-array , row-index-num [ , [ range-lookup-flag ] ] )
"
args
:
"
( lookup-value , table-array , row-index-num [ , [ range-lookup-flag ] ] )
"
};
};
};
};
function
cHYPERLINK
()
{
cBaseFunction
.
call
(
this
,
"
HYPERLINK
"
);
}
cHYPERLINK
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
/** @constructor */
function
cHYPERLINK
()
{
cBaseFunction
.
call
(
this
,
"
HYPERLINK
"
);
}
/** @constructor */
cHYPERLINK
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
function
cINDEX
()
{
// cBaseFunction.call( this, "INDEX" );
/** @constructor */
function
cINDEX
()
{
this
.
name
=
"
INDEX
"
;
this
.
name
=
"
INDEX
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -503,26 +447,24 @@ function cINDEX() {
...
@@ -503,26 +447,24 @@ function cINDEX() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
4
;
this
.
argumentsMax
=
4
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cINDEX
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cINDEX
.
prototype
.
Calculate
=
function
(
arg
)
{
cINDEX
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
]
&&
(
cElementType
.
empty
!==
arg
[
1
].
type
)
?
arg
[
1
]
:
new
cNumber
(
1
),
arg2
=
arg
[
2
]
&&
cINDEX
.
prototype
.
Calculate
=
function
(
arg
)
{
(
cElementType
.
empty
!==
arg
[
2
].
type
)
?
arg
[
2
]
:
new
cNumber
(
1
),
arg3
=
arg
[
3
]
&&
var
arg0
=
arg
[
0
],
(
cElementType
.
empty
!==
arg
[
3
].
type
)
?
arg
[
3
]
:
new
cNumber
(
1
),
res
;
arg1
=
arg
[
1
]
&&
!
(
arg
[
1
]
instanceof
cEmpty
)
?
arg
[
1
]
:
new
cNumber
(
1
),
arg2
=
arg
[
2
]
&&
!
(
arg
[
2
]
instanceof
cEmpty
)
?
arg
[
2
]
:
new
cNumber
(
1
),
arg3
=
arg
[
3
]
&&
!
(
arg
[
3
]
instanceof
cEmpty
)
?
arg
[
3
]
:
new
cNumber
(
1
),
res
;
if
(
arg0
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
tocArea
();
arg0
=
arg0
.
tocArea
();
if
(
!
arg0
)
if
(
!
arg0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
else
if
(
arg0
instanceof
cError
)
{
}
else
if
(
cElementType
.
error
===
arg0
.
type
)
{
return
this
.
value
=
arg0
;
return
this
.
value
=
arg0
;
}
}
...
@@ -530,68 +472,61 @@ cINDEX.prototype.Calculate = function ( arg ) {
...
@@ -530,68 +472,61 @@ cINDEX.prototype.Calculate = function ( arg ) {
arg2
=
arg2
.
tocNumber
();
arg2
=
arg2
.
tocNumber
();
arg3
=
arg3
.
tocNumber
();
arg3
=
arg3
.
tocNumber
();
if
(
arg1
instanceof
cError
||
arg2
instanceof
cError
||
arg3
instanceof
cError
)
{
if
(
cElementType
.
error
===
arg1
.
type
||
cElementType
.
error
===
arg2
.
type
||
cElementType
.
error
===
arg3
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
arg1
=
arg1
.
getValue
();
arg1
=
arg1
.
getValue
();
arg2
=
arg2
.
getValue
();
arg2
=
arg2
.
getValue
();
arg3
=
arg3
.
getValue
();
arg3
=
arg3
.
getValue
();
if
(
arg1
<
0
||
arg2
<
0
)
{
if
(
arg1
<
0
||
arg2
<
0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
if
(
arg0
instanceof
cArray
)
{
if
(
cElementType
.
array
===
arg0
.
type
)
{
res
=
arg0
.
getValue2
(
(
1
===
arg0
.
rowCount
||
0
===
arg1
)
?
0
:
arg1
-
1
,
0
===
arg2
?
0
:
arg2
-
1
);
res
=
arg0
.
getValue2
((
1
===
arg0
.
rowCount
||
0
===
arg1
)
?
0
:
arg1
-
1
,
0
===
arg2
?
0
:
arg2
-
1
);
}
}
else
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
else
if
(
arg0
instanceof
cArea
)
{
var
ws
=
arg0
.
getWS
(),
bbox
=
arg0
.
getBBox0
();
var
ws
=
arg0
.
getWS
(),
bbox
=
arg0
.
getBBox0
();
if
(
bbox
.
r1
==
bbox
.
r2
)
{
/*одна строка*/
if
(
bbox
.
r1
==
bbox
.
r2
)
{
/*одна строка*/
res
=
ws
.
getRange3
(
bbox
.
r1
,
bbox
.
c1
+
arg1
-
1
,
bbox
.
r1
,
bbox
.
c1
+
arg1
-
1
).
getCells
()[
0
].
getName
();
res
=
ws
.
getRange3
(
bbox
.
r1
,
bbox
.
c1
+
arg1
-
1
,
bbox
.
r1
,
bbox
.
c1
+
arg1
-
1
).
getCells
()[
0
].
getName
();
res
=
new
cRef
(
res
,
ws
);
res
=
new
cRef
(
res
,
ws
);
}
}
else
{
else
{
if
(
arg1
==
0
&&
arg2
>
0
)
{
if
(
arg1
==
0
&&
arg2
>
0
)
{
var
_a1
=
ws
.
getRange3
(
bbox
.
r1
,
bbox
.
c1
+
arg2
-
1
,
bbox
.
r1
,
bbox
.
c2
+
arg2
-
1
)
var
_a1
=
ws
.
getRange3
(
bbox
.
r1
,
bbox
.
c1
+
arg2
-
1
,
bbox
.
r1
,
bbox
.
c2
+
arg2
-
1
).
getCells
()[
0
].
getName
(),
.
getCells
()[
0
].
getName
(),
_a2
=
ws
.
getRange3
(
bbox
.
r2
,
bbox
.
c1
+
arg2
-
1
,
bbox
.
r2
,
bbox
.
c2
+
arg2
-
1
)
_a2
=
ws
.
getRange3
(
bbox
.
r2
,
bbox
.
c1
+
arg2
-
1
,
bbox
.
r2
,
bbox
.
c2
+
arg2
-
1
).
getCells
()[
0
].
getName
();
.
getCells
()[
0
].
getName
();
res
=
new
cArea
(
_a1
.
toString
()
+
"
:
"
+
_a2
.
toString
(),
ws
);
res
=
new
cArea
(
_a1
.
toString
()
+
"
:
"
+
_a2
.
toString
(),
ws
);
}
else
{
if
(
arg1
>
Math
.
abs
(
bbox
.
r1
-
bbox
.
r2
)
+
1
||
arg2
>
Math
.
abs
(
bbox
.
c1
-
bbox
.
c2
)
+
1
)
{
res
=
new
cError
(
cErrorType
.
bad_reference
);
}
else
{
res
=
new
cRef
(
ws
.
getRange3
(
bbox
.
r1
+
arg1
-
1
,
bbox
.
c1
+
arg2
-
1
,
bbox
.
r1
+
arg1
-
1
,
bbox
.
c1
+
arg2
-
1
)
.
getCells
()[
0
].
getName
(),
ws
);
}
}
else
{
if
(
arg1
>
Math
.
abs
(
bbox
.
r1
-
bbox
.
r2
)
+
1
||
arg2
>
Math
.
abs
(
bbox
.
c1
-
bbox
.
c2
)
+
1
)
{
res
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
res
=
new
cRef
(
ws
.
getRange3
(
bbox
.
r1
+
arg1
-
1
,
bbox
.
c1
+
arg2
-
1
,
bbox
.
r1
+
arg1
-
1
,
bbox
.
c1
+
arg2
-
1
).
getCells
()[
0
].
getName
(),
ws
);
}
}
}
}
else
if
(
cElementType
.
cell
===
arg0
.
type
||
cElementType
.
cell3D
===
arg0
.
type
)
{
}
if
((
arg1
==
0
||
arg1
==
1
)
&&
(
arg2
==
0
||
arg2
==
1
))
{
else
if
(
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
)
{
if
(
(
arg1
==
0
||
arg1
==
1
)
&&
(
arg2
==
0
||
arg2
==
1
)
)
{
res
=
arg0
.
tryConvert
();
res
=
arg0
.
tryConvert
();
}
}
}
}
else
{
else
{
res
=
new
cError
(
cErrorType
.
wrong_value_type
);
res
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
return
this
.
value
=
res
?
res
:
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
res
?
res
:
new
cError
(
cErrorType
.
bad_reference
);
};
};
cINDEX
.
prototype
.
getInfo
=
function
()
{
cINDEX
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( array , [ row-number ] [ , [ column-number ] ] )
"
+
this
.
name
+
"
( reference , [ row-number ] [ , [ column-number ] [ , [ area-number ] ] ] )
"
args
:
"
( array , [ row-number ] [ , [ column-number ] ] )
"
+
this
.
name
+
"
( reference , [ row-number ] [ , [ column-number ] [ , [ area-number ] ] ] )
"
};
};
};
};
/** @constructor */
function
cINDIRECT
()
{
// cBaseFunction.call( this, "INDIRECT" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 2 );
/** @constructor */
function
cINDIRECT
()
{
this
.
name
=
"
INDIRECT
"
;
this
.
name
=
"
INDIRECT
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -599,109 +534,103 @@ function cINDIRECT() {
...
@@ -599,109 +534,103 @@ function cINDIRECT() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
2
;
this
.
argumentsMax
=
2
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cINDIRECT
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cINDIRECT
.
prototype
.
Calculate
=
function
(
arg
)
{
cINDIRECT
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
var
t
=
this
,
arg0
=
arg
[
0
].
tocString
(),
arg1
=
arg
[
1
]
?
arg
[
1
]
:
cINDIRECT
.
prototype
.
Calculate
=
function
(
arg
)
{
new
cBool
(
true
),
r1
=
arguments
[
1
],
wb
=
r1
.
worksheet
.
workbook
,
o
=
{
var
t
=
this
,
arg0
=
arg
[
0
].
tocString
(),
Formula
:
""
,
pCurrPos
:
0
arg1
=
arg
[
1
]
?
arg
[
1
]
:
new
cBool
(
true
),
},
r2
=
arguments
[
2
],
ref
,
found_operand
;
r1
=
arguments
[
1
],
wb
=
r1
.
worksheet
.
workbook
,
o
=
{
Formula
:
""
,
pCurrPos
:
0
},
r2
=
arguments
[
2
],
ref
,
found_operand
;
function
parseReference
()
{
function
parseReference
()
{
if
(
(
ref
=
parserHelp
.
is3DRef
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
))[
0
]
)
{
if
((
ref
=
parserHelp
.
is3DRef
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
))[
0
])
{
var
_wsFrom
=
ref
[
1
],
var
_wsFrom
=
ref
[
1
],
_wsTo
=
(
(
ref
[
2
]
!==
null
)
&&
(
ref
[
2
]
!==
undefined
)
)
?
ref
[
2
]
:
_wsFrom
;
_wsTo
=
(
(
ref
[
2
]
!==
null
)
&&
(
ref
[
2
]
!==
undefined
)
)
?
ref
[
2
]
:
_wsFrom
;
if
(
!
(
wb
.
getWorksheetByName
(
_wsFrom
)
&&
wb
.
getWorksheetByName
(
_wsTo
)))
{
if
(
!
(
wb
.
getWorksheetByName
(
_wsFrom
)
&&
wb
.
getWorksheetByName
(
_wsTo
))
)
{
return
t
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
t
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
if
(
parserHelp
.
isArea
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
))
{
if
(
parserHelp
.
isArea
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
)
)
{
found_operand
=
new
cArea3D
(
o
.
operand_str
.
toUpperCase
(),
_wsFrom
,
_wsTo
,
wb
);
found_operand
=
new
cArea3D
(
o
.
operand_str
.
toUpperCase
(),
_wsFrom
,
_wsTo
,
wb
);
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
{
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
found_operand
.
isAbsolute
=
true
;
found_operand
.
isAbsolute
=
true
;
}
}
else
if
(
parserHelp
.
isRef
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
)
)
{
}
else
if
(
parserHelp
.
isRef
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
))
{
if
(
_wsTo
!=
_wsFrom
)
{
if
(
_wsTo
!=
_wsFrom
)
{
found_operand
=
new
cArea3D
(
o
.
operand_str
.
toUpperCase
(),
_wsFrom
,
_wsTo
,
wb
);
found_operand
=
new
cArea3D
(
o
.
operand_str
.
toUpperCase
(),
_wsFrom
,
_wsTo
,
wb
);
}
}
else
{
else
{
found_operand
=
new
cRef3D
(
o
.
operand_str
.
toUpperCase
(),
_wsFrom
,
wb
);
found_operand
=
new
cRef3D
(
o
.
operand_str
.
toUpperCase
(),
_wsFrom
,
wb
);
}
}
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
{
found_operand
.
isAbsolute
=
true
;
found_operand
.
isAbsolute
=
true
;
}
}
}
}
else
if
(
parserHelp
.
isArea
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
)
)
{
}
else
if
(
parserHelp
.
isArea
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
)
)
{
found_operand
=
new
cArea
(
o
.
operand_str
.
toUpperCase
(),
r1
.
worksheet
);
found_operand
=
new
cArea
(
o
.
operand_str
.
toUpperCase
(),
r1
.
worksheet
);
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
{
found_operand
.
isAbsolute
=
true
;
found_operand
.
isAbsolute
=
true
;
}
}
else
if
(
parserHelp
.
isRef
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
,
true
)
)
{
}
else
if
(
parserHelp
.
isRef
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
,
true
)
)
{
found_operand
=
new
cRef
(
o
.
operand_str
.
toUpperCase
(),
r1
.
worksheet
);
found_operand
=
new
cRef
(
o
.
operand_str
.
toUpperCase
(),
r1
.
worksheet
);
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
if
(
o
.
operand_str
.
indexOf
(
"
$
"
)
>
-
1
)
{
found_operand
.
isAbsolute
=
true
;
found_operand
.
isAbsolute
=
true
;
}
}
else
if
(
parserHelp
.
isName
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
,
wb
)[
0
]
)
{
}
else
if
(
parserHelp
.
isName
.
call
(
o
,
o
.
Formula
,
o
.
pCurrPos
,
wb
)[
0
]
)
{
found_operand
=
new
AscCommonExcel
.
cName
(
o
.
operand_str
,
wb
,
r1
.
worksheet
);
found_operand
=
new
AscCommonExcel
.
cName
(
o
.
operand_str
,
wb
,
r1
.
worksheet
);
}
}
}
}
if
(
arg0
instanceof
cArray
)
{
if
(
cElementType
.
array
===
arg0
.
type
)
{
var
ret
=
new
cArray
();
var
ret
=
new
cArray
();
arg0
.
foreach
(
function
(
elem
,
r
)
{
arg0
.
foreach
(
function
(
elem
,
r
)
{
o
=
{
Formula
:
elem
.
toString
(),
pCurrPos
:
0
};
o
=
{
Formula
:
elem
.
toString
(),
pCurrPos
:
0
};
parseReference
();
parseReference
();
if
(
!
ret
.
array
[
r
]
)
if
(
!
ret
.
array
[
r
])
{
ret
.
addRow
();
ret
.
addRow
();
ret
.
addElement
(
found_operand
)
}
);
return
this
.
value
=
ret
;
}
}
else
{
ret
.
addElement
(
found_operand
)
});
return
this
.
value
=
ret
;
}
else
{
o
.
Formula
=
arg0
.
toString
();
o
.
Formula
=
arg0
.
toString
();
parseReference
();
parseReference
();
}
}
if
(
found_operand
)
{
if
(
found_operand
)
{
if
(
found_operand
instanceof
AscCommonExcel
.
cName
)
{
if
(
cElementType
.
name
===
found_operand
.
type
)
{
found_operand
=
found_operand
.
toRef
();
found_operand
=
found_operand
.
toRef
();
}
}
var
cellName
=
r1
.
getFirst
().
getID
(),
wsId
=
r1
.
worksheet
.
getId
();
var
cellName
=
r1
.
getFirst
().
getID
(),
wsId
=
r1
.
worksheet
.
getId
();
if
(
(
found_operand
instanceof
cRef
||
found_operand
instanceof
cRef3D
||
found_operand
instanceof
cArea
)
&&
found_operand
.
isValid
()
)
{
if
((
cElementType
.
cell
===
found_operand
.
type
||
cElementType
.
cell3D
===
found_operand
.
type
||
cElementType
.
cellsRange
===
found_operand
.
type
)
&&
found_operand
.
isValid
())
{
var
nFrom
,
nTo
;
var
nFrom
,
nTo
;
if
(
r2
)
{
if
(
r2
)
{
nFrom
=
r2
.
defName
;
nFrom
=
r2
.
defName
;
}
}
else
{
else
{
nFrom
=
wb
.
dependencyFormulas
.
addNode
(
wsId
,
cellName
);
nFrom
=
wb
.
dependencyFormulas
.
addNode
(
wsId
,
cellName
);
}
}
nTo
=
wb
.
dependencyFormulas
.
addNode
(
found_operand
.
getWsId
(),
found_operand
.
_cells
);
nTo
=
wb
.
dependencyFormulas
.
addNode
(
found_operand
.
getWsId
(),
found_operand
.
_cells
);
found_operand
.
setNode
(
nTo
);
found_operand
.
setNode
(
nTo
);
wb
.
dependencyFormulas
.
addEdge2
(
nFrom
,
nTo
);
wb
.
dependencyFormulas
.
addEdge2
(
nFrom
,
nTo
);
}
}
else
if
(
cElementType
.
cellsRange3D
===
found_operand
.
type
&&
found_operand
.
isValid
())
{
else
if
(
found_operand
instanceof
cArea3D
&&
found_operand
.
isValid
()
)
{
var
wsR
=
found_operand
.
wsRange
(),
nTo
,
_cell
=
found_operand
.
_cells
.
replace
(
/
\$
/g
,
""
);
var
wsR
=
found_operand
.
wsRange
(),
nTo
,
_cell
=
found_operand
.
_cells
.
replace
(
/
\$
/g
,
""
);
for
(
var
j
=
0
;
j
<
wsR
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
wsR
.
length
;
j
++
)
{
if
(
r2
)
{
if
(
r2
)
{
nTo
=
wb
.
dependencyFormulas
.
addNode
(
wsR
[
j
].
Id
,
_cell
);
nTo
=
wb
.
dependencyFormulas
.
addNode
(
wsR
[
j
].
Id
,
_cell
);
wb
.
dependencyFormulas
.
addEdge2
(
r2
.
defName
,
nTo
);
wb
.
dependencyFormulas
.
addEdge2
(
r2
.
defName
,
nTo
);
}
else
{
wb
.
dependencyFormulas
.
addEdge
(
wsId
,
cellName
.
replace
(
/
\$
/g
,
""
),
wsR
[
j
].
Id
,
_cell
);
}
}
else
wb
.
dependencyFormulas
.
addEdge
(
wsId
,
cellName
.
replace
(
/
\$
/g
,
""
),
wsR
[
j
].
Id
,
_cell
);
}
}
}
}
...
@@ -709,21 +638,17 @@ cINDIRECT.prototype.Calculate = function ( arg ) {
...
@@ -709,21 +638,17 @@ cINDIRECT.prototype.Calculate = function ( arg ) {
return
this
.
value
=
found_operand
;
return
this
.
value
=
found_operand
;
}
}
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
};
};
cINDIRECT
.
prototype
.
getInfo
=
function
()
{
cINDIRECT
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( ref-text [ , [ A1-ref-style-flag ] ] )
"
args
:
"
( ref-text [ , [ A1-ref-style-flag ] ] )
"
};
};
};
};
function
cLOOKUP
()
{
// cBaseFunction.call( this, "LOOKUP" );
// this.setArgumentsMin( 2 );
// this.setArgumentsMax( 3 );
/** @constructor */
function
cLOOKUP
()
{
this
.
name
=
"
LOOKUP
"
;
this
.
name
=
"
LOOKUP
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -731,156 +656,152 @@ function cLOOKUP() {
...
@@ -731,156 +656,152 @@ function cLOOKUP() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
3
;
this
.
argumentsMax
=
3
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cLOOKUP
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cLOOKUP
.
prototype
.
Calculate
=
function
(
arg
)
{
cLOOKUP
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
this
.
argumentsCurrent
==
2
?
arg1
:
arg
[
2
],
resC
=
-
1
,
resR
=
-
1
;
cLOOKUP
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
this
.
argumentsCurrent
==
2
?
arg1
:
arg
[
2
],
resC
=
-
1
,
resR
=
-
1
;
if
(
arg0
instanceof
cError
)
{
if
(
cElementType
.
error
===
arg0
.
type
)
{
return
this
.
value
=
arg0
;
return
this
.
value
=
arg0
;
}
}
if
(
arg0
instanceof
cRef
)
{
if
(
cElementType
.
cell
===
arg0
.
type
)
{
arg0
=
arg0
.
tryConvert
();
arg0
=
arg0
.
tryConvert
();
}
}
function
arrFinder
(
arr
)
{
function
arrFinder
(
arr
)
{
if
(
arr
.
getRowCount
()
>
arr
.
getCountElementInRow
()
)
{
if
(
arr
.
getRowCount
()
>
arr
.
getCountElementInRow
()
)
{
//ищем в первом столбце
//ищем в первом столбце
resC
=
arr
.
getCountElementInRow
()
>
1
?
1
:
0
;
resC
=
arr
.
getCountElementInRow
()
>
1
?
1
:
0
;
var
arrCol
=
arr
.
getCol
(
0
);
var
arrCol
=
arr
.
getCol
(
0
);
resR
=
_func
.
binarySearch
(
arg0
,
arrCol
);
resR
=
_func
.
binarySearch
(
arg0
,
arrCol
);
}
}
else
{
else
{
//ищем в первой строке
//ищем в первой строке
resR
=
arr
.
getRowCount
()
>
1
?
1
:
0
;
resR
=
arr
.
getRowCount
()
>
1
?
1
:
0
;
var
arrRow
=
arr
.
getRow
(
0
);
var
arrRow
=
arr
.
getRow
(
0
);
resC
=
_func
.
binarySearch
(
arg0
,
arrRow
);
resC
=
_func
.
binarySearch
(
arg0
,
arrRow
);
}
}
}
}
if
(
!
(
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
||
arg1
instanceof
cArray
)
&&
(
arg2
instanceof
cArea
||
arg2
instanceof
cArea3D
||
arg2
instanceof
cArray
)
))
{
if
(
!
(
(
cElementType
.
cellsRange
===
arg1
.
type
||
cElementType
.
cellsRange3D
===
arg1
.
type
||
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
cElementType
.
array
===
arg1
.
type
)
&&
(
cElementType
.
cellsRange
===
arg2
.
type
||
cElementType
.
cellsRange3D
===
arg2
.
type
||
cElementType
.
array
===
arg2
.
type
)
))
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
if
(
arg1
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
if
(
cElementType
.
array
===
arg1
.
type
&&
cElementType
.
array
===
arg2
.
type
)
{
if
(
arg1
.
getRowCount
()
!=
arg2
.
getRowCount
()
&&
arg1
.
getCountElementInRow
()
!=
arg2
.
getCountElementInRow
()
)
{
if
(
arg1
.
getRowCount
()
!=
arg2
.
getRowCount
()
&&
arg1
.
getCountElementInRow
()
!=
arg2
.
getCountElementInRow
()
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
arrFinder
(
arg1
);
arrFinder
(
arg1
);
if
(
resR
<=
-
1
&&
resC
<=
-
1
||
resR
<=
-
2
||
resC
<=
-
2
)
{
if
(
resR
<=
-
1
&&
resC
<=
-
1
||
resR
<=
-
2
||
resC
<=
-
2
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
return
this
.
value
=
arg2
.
getElementRowCol
(
resR
,
resC
);
return
this
.
value
=
arg2
.
getElementRowCol
(
resR
,
resC
);
}
}
else
if
(
cElementType
.
array
===
arg1
.
type
||
cElementType
.
array
===
arg2
.
type
)
{
else
if
(
arg1
instanceof
cArray
||
arg2
instanceof
cArray
)
{
var
_arg1
,
_arg2
;
var
_arg1
,
_arg2
;
_arg1
=
arg1
instanceof
cArray
?
arg1
:
arg2
;
_arg1
=
cElementType
.
array
===
arg1
.
type
?
arg1
:
arg2
;
_arg2
=
arg2
instanceof
cArray
?
arg1
:
arg2
;
_arg2
=
cElementType
.
array
===
arg2
.
type
?
arg1
:
arg2
;
var
BBox
=
_arg2
.
getBBox
();
var
BBox
=
_arg2
.
getBBox
();
if
(
_arg1
.
getRowCount
()
!=
(
BBox
.
r2
-
BBox
.
r1
)
&&
_arg1
.
getCountElementInRow
()
!=
(
BBox
.
c2
-
BBox
.
c1
)
)
{
if
(
_arg1
.
getRowCount
()
!=
(
BBox
.
r2
-
BBox
.
r1
)
&&
_arg1
.
getCountElementInRow
()
!=
(
BBox
.
c2
-
BBox
.
c1
)
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
arrFinder
(
_arg1
);
arrFinder
(
_arg1
);
if
(
resR
<=
-
1
&&
resC
<=
-
1
||
resR
<=
-
2
||
resC
<=
-
2
)
{
if
(
resR
<=
-
1
&&
resC
<=
-
1
||
resR
<=
-
2
||
resC
<=
-
2
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
var
c
=
new
CellAddress
(
BBox
.
r1
+
resR
,
BBox
.
c1
+
resC
);
var
c
=
new
CellAddress
(
BBox
.
r1
+
resR
,
BBox
.
c1
+
resC
);
return
this
.
value
=
checkTypeCell
(
_arg2
.
getWS
().
_getCellNoEmpty
(
c
.
getRow0
(),
c
.
getCol0
()
).
getValueWithoutFormat
()
);
return
this
.
value
=
}
checkTypeCell
(
_arg2
.
getWS
().
_getCellNoEmpty
(
c
.
getRow0
(),
c
.
getCol0
()).
getValueWithoutFormat
());
else
{
}
else
{
var
arg1Range
=
arg1
.
getRange
(),
arg2Range
=
arg2
.
getRange
();
var
arg1Range
=
arg1
.
getRange
(),
arg2Range
=
arg2
.
getRange
();
if
(
arg1
instanceof
cArea3D
&&
arg1Range
.
length
>
1
||
arg2
instanceof
cArea3D
&&
arg2Range
.
length
>
1
)
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
&&
arg1Range
.
length
>
1
||
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
cElementType
.
cellsRange3D
===
arg2
.
type
&&
arg2Range
.
length
>
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
if
(
arg1
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
)
{
arg1Range
=
arg1
.
getMatrix
()[
0
];
arg1Range
=
arg1
.
getMatrix
()[
0
];
}
}
else
if
(
cElementType
.
cellsRange
===
arg1
.
type
)
{
else
if
(
arg1
instanceof
cArea
)
{
arg1Range
=
arg1
.
getMatrix
();
arg1Range
=
arg1
.
getMatrix
();
}
}
if
(
arg2
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange3D
===
arg2
.
type
)
{
arg2Range
=
arg2
.
getMatrix
()[
0
];
arg2Range
=
arg2
.
getMatrix
()[
0
];
}
}
else
if
(
cElementType
.
cellsRange
===
arg2
.
type
)
{
else
if
(
arg2
instanceof
cArea
)
{
arg2Range
=
arg2
.
getMatrix
();
arg2Range
=
arg2
.
getMatrix
();
}
}
var
index
=
_func
.
binarySearch
(
arg0
,
function
()
{
var
index
=
_func
.
binarySearch
(
arg0
,
function
()
{
var
a
=
[];
var
a
=
[];
for
(
var
i
=
0
;
i
<
arg1Range
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arg1Range
.
length
;
i
++
)
{
a
.
push
(
arg1Range
[
i
][
0
]
)
a
.
push
(
arg1Range
[
i
][
0
]
)
}
}
return
a
;
return
a
;
}()
);
}()
);
if
(
index
<
0
)
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
if
(
index
<
0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
var
ws
=
arg1
instanceof
cArea3D
&&
arg1
.
isSingleSheet
()
?
arg1
.
getWS
()
:
arg1
.
ws
;
var
ws
=
cElementType
.
cellsRange3D
===
arg1
.
type
&&
arg1
.
isSingleSheet
()
?
arg1
.
getWS
()
:
arg1
.
ws
;
if
(
arg1
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
)
{
if
(
arg1
.
isSingleSheet
()
)
{
if
(
arg1
.
isSingleSheet
())
{
ws
=
arg1
.
getWS
();
ws
=
arg1
.
getWS
();
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
}
else
if
(
cElementType
.
cellsRange
===
arg1
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
else
if
(
arg1
instanceof
cArea
){
ws
=
arg1
.
getWS
();
ws
=
arg1
.
getWS
();
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
if
(
this
.
argumentsCurrent
==
2
)
{
if
(
this
.
argumentsCurrent
==
2
)
{
var
b
=
arg2
.
getBBox
();
var
b
=
arg2
.
getBBox
();
if
(
arg1Range
[
0
].
length
>=
2
)
{
if
(
arg1Range
[
0
].
length
>=
2
)
{
return
this
.
value
=
new
cRef
(
ws
.
getCell3
(
(
b
.
r1
-
1
)
+
index
,
(
b
.
c2
-
1
)
+
0
).
getName
(),
ws
);
return
this
.
value
=
new
cRef
(
ws
.
getCell3
((
b
.
r1
-
1
)
+
index
,
(
b
.
c2
-
1
)
+
0
).
getName
(),
ws
);
}
else
{
return
this
.
value
=
new
cRef
(
ws
.
getCell3
((
b
.
r1
-
1
)
+
0
,
(
b
.
c1
-
1
)
+
index
).
getName
(),
ws
);
}
}
else
}
else
{
return
this
.
value
=
new
cRef
(
ws
.
getCell3
(
(
b
.
r1
-
1
)
+
0
,
(
b
.
c1
-
1
)
+
index
).
getName
(),
ws
);
}
else
{
var
b
=
arg2
.
getBBox
();
var
b
=
arg2
.
getBBox
();
if
(
arg2Range
.
length
==
1
)
{
if
(
arg2Range
.
length
==
1
)
{
return
this
.
value
=
new
cRef
(
ws
.
getCell3
(
(
b
.
r1
-
1
)
+
0
,
(
b
.
c1
-
1
)
+
index
).
getName
(),
ws
);
return
this
.
value
=
new
cRef
(
ws
.
getCell3
((
b
.
r1
-
1
)
+
0
,
(
b
.
c1
-
1
)
+
index
).
getName
(),
ws
);
}
else
{
return
this
.
value
=
new
cRef
(
ws
.
getCell3
((
b
.
r1
-
1
)
+
index
,
(
b
.
c1
-
1
)
+
0
).
getName
(),
ws
);
}
}
else
return
this
.
value
=
new
cRef
(
ws
.
getCell3
(
(
b
.
r1
-
1
)
+
index
,
(
b
.
c1
-
1
)
+
0
).
getName
(),
ws
);
}
}
}
}
};
};
cLOOKUP
.
prototype
.
getInfo
=
function
()
{
cLOOKUP
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( lookup-value , lookup-vector , result-vector )
"
args
:
"
( lookup-value , lookup-vector , result-vector )
"
};
};
};
};
function
cMATCH
()
{
// cBaseFunction.call( this, "MATCH" );
/** @constructor */
function
cMATCH
()
{
this
.
name
=
"
MATCH
"
;
this
.
name
=
"
MATCH
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -888,123 +809,112 @@ function cMATCH() {
...
@@ -888,123 +809,112 @@ function cMATCH() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
3
;
this
.
argumentsMax
=
3
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cMATCH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cMATCH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cMATCH
.
prototype
.
Calculate
=
function
(
arg
)
{
cMATCH
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
new
cNumber
(
1
);
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
new
cNumber
(
1
);
function
findMatch
(
a0
,
a1
,
a2
)
{
function
findMatch
(
a0
,
a1
,
a2
)
{
var
a1RowCount
=
a1
.
length
,
a1ColumnCount
=
a1
[
0
].
length
,
var
a1RowCount
=
a1
.
length
,
a1ColumnCount
=
a1
[
0
].
length
,
a0Value
=
a0
.
getValue
(),
a2Value
=
a2
.
getValue
(),
arr
=
[],
res
=
new
cError
(
cErrorType
.
not_available
),
index
=
-
1
;
a0Value
=
a0
.
getValue
(),
a2Value
=
a2
.
getValue
(),
arr
=
[],
res
=
new
cError
(
cErrorType
.
not_available
),
index
=
-
1
;
if
(
a1RowCount
>
1
&&
a1ColumnCount
>
1
)
{
if
(
a1RowCount
>
1
&&
a1ColumnCount
>
1
)
{
return
new
cError
(
cErrorType
.
not_available
);
return
new
cError
(
cErrorType
.
not_available
);
}
}
else
if
(
a1RowCount
==
1
&&
a1ColumnCount
>
1
)
{
else
if
(
a1RowCount
==
1
&&
a1ColumnCount
>
1
)
{
for
(
var
i
=
0
;
i
<
a1ColumnCount
;
i
++
)
{
for
(
var
i
=
0
;
i
<
a1ColumnCount
;
i
++
)
{
arr
[
i
]
=
a1
[
0
][
i
].
getValue
();
arr
[
i
]
=
a1
[
0
][
i
].
getValue
();
}
}
}
}
else
if
(
a1RowCount
>
1
&&
a1ColumnCount
==
1
)
{
else
if
(
a1RowCount
>
1
&&
a1ColumnCount
==
1
)
{
for
(
var
i
=
0
;
i
<
a1RowCount
;
i
++
)
{
for
(
var
i
=
0
;
i
<
a1RowCount
;
i
++
)
{
arr
[
i
]
=
a1
[
i
][
0
].
getValue
();
arr
[
i
]
=
a1
[
i
][
0
].
getValue
();
}
}
}
}
else
{
else
{
arr
[
0
]
=
a1
[
0
][
0
];
arr
[
0
]
=
a1
[
0
][
0
];
}
}
if
(
!
(
a2Value
==
1
||
a2Value
==
0
||
a2Value
==
-
1
)
)
{
if
(
!
(
a2Value
==
1
||
a2Value
==
0
||
a2Value
==
-
1
)
)
{
return
new
cError
(
cErrorType
.
not_numeric
);
return
new
cError
(
cErrorType
.
not_numeric
);
}
}
if
(
a2Value
==
-
1
)
{
if
(
a2Value
==
-
1
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
>=
a0Value
)
{
if
(
arr
[
i
]
>=
a0Value
)
{
index
=
i
;
index
=
i
;
}
}
else
{
else
break
;
break
;
}
}
}
}
else
if
(
a2Value
==
0
)
{
}
else
if
(
a2Value
==
0
)
{
if
(
a0
instanceof
cString
)
{
if
(
cElementType
.
string
===
a0
.
type
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
AscCommonExcel
.
searchRegExp2
(
arr
[
i
].
toString
(),
a0Value
)
)
{
if
(
AscCommonExcel
.
searchRegExp2
(
arr
[
i
].
toString
(),
a0Value
)
)
{
index
=
i
;
index
=
i
;
break
;
break
;
}
}
}
}
}
}
else
{
else
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
==
a0Value
)
{
if
(
arr
[
i
]
==
a0Value
)
{
index
=
i
;
index
=
i
;
break
;
break
;
}
}
}
}
}
}
}
}
else
if
(
a2Value
==
1
)
{
else
if
(
a2Value
==
1
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
<=
a0Value
)
{
if
(
arr
[
i
]
<=
a0Value
)
{
index
=
i
;
index
=
i
;
}
}
else
{
else
break
;
break
;
}
}
}
}
}
if
(
index
>
-
1
)
if
(
index
>
-
1
)
{
res
=
new
cNumber
(
index
+
1
);
res
=
new
cNumber
(
index
+
1
);
}
return
res
;
return
res
;
}
}
if
(
arg0
instanceof
cArea3D
||
arg0
instanceof
cArray
||
arg0
instanceof
cArea
)
{
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
||
cElementType
.
array
===
arg0
.
type
||
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
cElementType
.
cellsRange
===
arg0
.
type
)
{
}
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
else
if
(
arg0
instanceof
cError
)
{
}
else
if
(
cElementType
.
error
===
arg0
.
type
)
{
return
this
.
value
=
arg0
;
return
this
.
value
=
arg0
;
}
}
if
(
arg1
instanceof
cArray
||
arg1
instanceof
cArea
)
if
(
cElementType
.
array
===
arg1
.
type
||
cElementType
.
cellsRange
===
arg1
.
type
)
{
arg1
=
arg1
.
getMatrix
();
arg1
=
arg1
.
getMatrix
();
else
if
(
arg1
instanceof
cArea3D
&&
arg1
.
wsFrom
==
arg1
.
wsTo
)
}
else
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
&&
arg1
.
wsFrom
==
arg1
.
wsTo
)
{
arg1
=
arg1
.
getMatrix
()[
0
];
arg1
=
arg1
.
getMatrix
()[
0
];
else
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
if
(
arg2
instanceof
cNumber
||
arg2
instanceof
cBool
)
{
}
}
else
if
(
arg2
instanceof
cError
)
{
if
(
cElementType
.
number
===
arg2
.
type
||
cElementType
.
bool
===
arg2
.
type
)
{
}
else
if
(
cElementType
.
error
===
arg2
.
type
)
{
return
this
.
value
=
arg2
;
return
this
.
value
=
arg2
;
}
}
else
{
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
return
this
.
value
=
findMatch
(
arg0
,
arg1
,
arg2
)
return
this
.
value
=
findMatch
(
arg0
,
arg1
,
arg2
)
};
};
cMATCH
.
prototype
.
getInfo
=
function
()
{
cMATCH
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( lookup-value , lookup-array [ , [ match-type ]] )
"
args
:
"
( lookup-value , lookup-array [ , [ match-type ]] )
"
};
};
};
};
function
cOFFSET
()
{
// cBaseFunction.call( this, "OFFSET" );
/** @constructor */
function
cOFFSET
()
{
this
.
name
=
"
OFFSET
"
;
this
.
name
=
"
OFFSET
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -1012,37 +922,32 @@ function cOFFSET() {
...
@@ -1012,37 +922,32 @@ function cOFFSET() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
5
;
this
.
argumentsMax
=
5
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cOFFSET
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cOFFSET
.
prototype
.
Calculate
=
function
(
arg
)
{
cOFFSET
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cOFFSET
.
prototype
.
Calculate
=
function
(
arg
)
{
function
validBBOX
(
bbox
)
{
function
validBBOX
(
bbox
)
{
return
0
<=
bbox
.
r1
&&
bbox
.
r1
<=
gc_nMaxRow0
&&
return
0
<=
bbox
.
r1
&&
bbox
.
r1
<=
gc_nMaxRow0
&&
0
<=
bbox
.
c1
&&
bbox
.
c1
<=
gc_nMaxCol0
&&
0
<=
bbox
.
r2
&&
0
<=
bbox
.
c1
&&
bbox
.
c1
<=
gc_nMaxCol0
&&
bbox
.
r2
<=
gc_nMaxRow0
&&
0
<=
bbox
.
c2
&&
bbox
.
c2
<=
gc_nMaxCol0
;
0
<=
bbox
.
r2
&&
bbox
.
r2
<=
gc_nMaxRow0
&&
0
<=
bbox
.
c2
&&
bbox
.
c2
<=
gc_nMaxCol0
;
}
}
var
arg0
=
arg
[
0
],
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
].
tocNumber
(),
arg2
=
arg
[
2
].
tocNumber
(),
arg3
=
new
cNumber
(
-
1
),
arg4
=
new
cNumber
(
-
1
);
arg1
=
arg
[
1
].
tocNumber
(),
arg2
=
arg
[
2
].
tocNumber
(),
arg3
=
new
cNumber
(
-
1
),
arg4
=
new
cNumber
(
-
1
);
if
(
this
.
argumentsCurrent
>=
4
)
{
if
(
this
.
argumentsCurrent
>=
4
)
{
arg3
=
arg
[
3
].
tocNumber
();
arg3
=
arg
[
3
].
tocNumber
();
}
}
if
(
this
.
argumentsCurrent
==
5
)
{
if
(
this
.
argumentsCurrent
==
5
)
{
arg4
=
arg
[
4
].
tocNumber
();
arg4
=
arg
[
4
].
tocNumber
();
}
}
if
(
arg1
instanceof
cError
||
arg2
instanceof
cError
||
arg3
instanceof
cError
||
arg4
instanceof
cError
)
{
if
(
cElementType
.
error
===
arg1
.
type
||
cElementType
.
error
===
arg2
.
type
||
cElementType
.
error
===
arg3
.
type
||
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
arg4
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
arg1
=
arg1
.
getValue
();
arg1
=
arg1
.
getValue
();
...
@@ -1051,115 +956,104 @@ cOFFSET.prototype.Calculate = function ( arg ) {
...
@@ -1051,115 +956,104 @@ cOFFSET.prototype.Calculate = function ( arg ) {
arg4
=
arg4
.
getValue
();
arg4
=
arg4
.
getValue
();
if
(
arg3
<
0
)
{
if
(
arg3
<
0
)
{
arg3
=
1
;
arg3
=
1
;
}
}
if
(
arg4
<
0
)
{
if
(
arg4
<
0
)
{
arg4
=
1
;
arg4
=
1
;
}
}
if
(
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
)
{
if
(
cElementType
.
cell
===
arg0
.
type
||
cElementType
.
cell3D
===
arg0
.
type
)
{
var
range
=
arg0
.
getRange
(),
var
range
=
arg0
.
getRange
(),
bbox
=
range
.
getBBox0
(),
box
=
{
r1
:
0
,
r2
:
0
,
c1
:
0
,
c2
:
0
},
ref
;
bbox
=
range
.
getBBox0
(),
box
=
{
r1
:
0
,
r2
:
0
,
c1
:
0
,
c2
:
0
},
ref
;
box
.
r1
=
bbox
.
r1
+
arg1
;
box
.
r1
=
bbox
.
r1
+
arg1
;
box
.
c1
=
bbox
.
c1
+
arg2
;
box
.
c1
=
bbox
.
c1
+
arg2
;
box
.
r2
=
bbox
.
r1
+
arg1
+
arg3
-
1
;
box
.
r2
=
bbox
.
r1
+
arg1
+
arg3
-
1
;
box
.
c2
=
bbox
.
c1
+
arg2
+
arg4
-
1
;
box
.
c2
=
bbox
.
c1
+
arg2
+
arg4
-
1
;
if
(
!
validBBOX
(
box
)
)
{
if
(
!
validBBOX
(
box
)
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
var
wsName
=
arg0
.
ws
.
getName
();
var
wsName
=
arg0
.
ws
.
getName
();
if
(
box
.
r1
==
box
.
r2
&&
box
.
c1
==
box
.
c2
)
{
if
(
box
.
r1
==
box
.
r2
&&
box
.
c1
==
box
.
c2
)
{
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
);
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
);
this
.
value
=
(
arg0
instanceof
cRef
)
?
new
cRef
(
ref
,
arg0
.
ws
)
:
new
cRef3D
(
ref
,
wsName
,
arg0
.
wb
);
this
.
value
=
(
cElementType
.
cell
===
arg0
.
type
)
?
new
cRef
(
ref
,
arg0
.
ws
)
:
new
cRef3D
(
ref
,
wsName
,
arg0
.
wb
);
}
}
else
{
else
{
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
)
+
"
:
"
+
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
)
+
"
:
"
+
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c2
+
1
)
+
_getRowTitle
(
box
.
r2
);
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c2
+
1
)
+
_getRowTitle
(
box
.
r2
);
this
.
value
=
this
.
value
=
(
arg0
instanceof
cRef
)
?
new
cArea
(
ref
,
arg0
.
ws
)
:
new
cArea3D
(
ref
,
wsName
,
wsName
,
arg0
.
wb
);
(
cElementType
.
cell
===
arg0
.
type
)
?
new
cArea
(
ref
,
arg0
.
ws
)
:
new
cArea3D
(
ref
,
wsName
,
wsName
,
arg0
.
wb
);
}
}
}
}
else
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
else
if
(
arg0
instanceof
cArea
)
{
var
bbox
=
arg0
.
getBBox0
(),
var
bbox
=
arg0
.
getBBox0
(),
box
=
{
r1
:
0
,
r2
:
0
,
c1
:
0
,
c2
:
0
},
ref
;
box
=
{
r1
:
0
,
r2
:
0
,
c1
:
0
,
c2
:
0
},
ref
;
box
.
r1
=
bbox
.
r1
+
arg1
;
box
.
r1
=
bbox
.
r1
+
arg1
;
box
.
c1
=
bbox
.
c1
+
arg2
;
box
.
c1
=
bbox
.
c1
+
arg2
;
box
.
r2
=
bbox
.
r1
+
arg1
+
arg3
-
1
;
box
.
r2
=
bbox
.
r1
+
arg1
+
arg3
-
1
;
box
.
c2
=
bbox
.
c1
+
arg2
+
arg4
-
1
;
box
.
c2
=
bbox
.
c1
+
arg2
+
arg4
-
1
;
if
(
!
validBBOX
(
box
)
)
{
if
(
!
validBBOX
(
box
))
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
if
(
box
.
r1
==
box
.
r2
&&
box
.
c1
==
box
.
c2
)
{
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
);
this
.
value
=
new
cRef
(
ref
,
arg0
.
ws
);
}
}
else
{
if
(
box
.
r1
==
box
.
r2
&&
box
.
c1
==
box
.
c2
)
{
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
)
+
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
);
"
:
"
+
this
.
value
=
new
cRef
(
ref
,
arg0
.
ws
);
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c2
+
1
)
+
_getRowTitle
(
box
.
r2
);
}
else
{
this
.
value
=
new
cArea
(
ref
,
arg0
.
ws
);
ref
=
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c1
+
1
)
+
_getRowTitle
(
box
.
r1
)
+
"
:
"
+
g_oCellAddressUtils
.
colnumToColstrFromWsView
(
box
.
c2
+
1
)
+
_getRowTitle
(
box
.
r2
);
this
.
value
=
new
cArea
(
ref
,
arg0
.
ws
);
}
}
}
}
else
{
else
{
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
if
(
this
.
value
instanceof
cArea
||
this
.
value
instanceof
cRef
||
this
.
value
instanceof
cRef3D
||
this
.
value
instanceof
cArea3D
)
{
if
(
cElementType
.
cellsRange
===
this
.
value
.
type
||
cElementType
.
cell
===
this
.
value
.
type
||
var
r1
=
arguments
[
1
],
r2
=
arguments
[
2
],
wb
=
r1
.
worksheet
.
workbook
,
cellName
=
r1
.
getFirst
().
getID
(),
wsId
=
r1
.
worksheet
.
getId
();
cElementType
.
cell3D
===
this
.
value
.
type
||
cElementType
.
cellsRange3D
===
this
.
value
.
type
)
{
var
r1
=
arguments
[
1
],
r2
=
arguments
[
2
],
wb
=
r1
.
worksheet
.
workbook
,
cellName
=
r1
.
getFirst
()
.
getID
(),
wsId
=
r1
.
worksheet
.
getId
();
if
(
(
this
.
value
instanceof
cRef
||
this
.
value
instanceof
cRef3D
||
this
.
value
instanceof
cArea
)
&&
this
.
value
.
isValid
()
)
{
if
((
cElementType
.
cell
===
this
.
value
.
type
||
cElementType
.
cell3D
===
this
.
value
.
type
||
cElementType
.
cellsRange
===
this
.
value
.
type
)
&&
this
.
value
.
isValid
())
{
var
nFrom
,
nTo
;
var
nFrom
,
nTo
;
if
(
r2
)
{
if
(
r2
)
{
nFrom
=
r2
.
defName
;
nFrom
=
r2
.
defName
;
}
}
else
{
else
{
nFrom
=
wb
.
dependencyFormulas
.
addNode
(
wsId
,
cellName
);
nFrom
=
wb
.
dependencyFormulas
.
addNode
(
wsId
,
cellName
);
}
}
nTo
=
wb
.
dependencyFormulas
.
addNode
(
this
.
value
.
getWsId
(),
this
.
value
.
_cells
.
replace
(
/
\$
/g
,
""
)
);
nTo
=
wb
.
dependencyFormulas
.
addNode
(
this
.
value
.
getWsId
(),
this
.
value
.
_cells
.
replace
(
/
\$
/g
,
""
));
this
.
value
.
setNode
(
nTo
);
this
.
value
.
setNode
(
nTo
);
wb
.
dependencyFormulas
.
addEdge2
(
nFrom
,
nTo
);
wb
.
dependencyFormulas
.
addEdge2
(
nFrom
,
nTo
);
}
}
else
if
(
cElementType
.
cellsRange3D
===
this
.
value
.
type
&&
this
.
value
.
isValid
())
{
else
if
(
this
.
value
instanceof
cArea3D
&&
this
.
value
.
isValid
()
)
{
var
wsR
=
this
.
value
.
wsRange
(),
nTo
,
_cell
=
this
.
value
.
_cells
.
replace
(
/
\$
/g
,
""
);
var
wsR
=
this
.
value
.
wsRange
(),
nTo
,
_cell
=
this
.
value
.
_cells
.
replace
(
/
\$
/g
,
""
);
for
(
var
j
=
0
;
j
<
wsR
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
wsR
.
length
;
j
++
)
{
if
(
r2
)
{
if
(
r2
)
{
nTo
=
wb
.
dependencyFormulas
.
addNode
(
wsR
[
j
].
Id
,
_cell
);
nTo
=
wb
.
dependencyFormulas
.
addNode
(
wsR
[
j
].
Id
,
_cell
);
wb
.
dependencyFormulas
.
addEdge2
(
r2
.
defName
,
nTo
);
wb
.
dependencyFormulas
.
addEdge2
(
r2
.
defName
,
nTo
);
}
else
{
wb
.
dependencyFormulas
.
addEdge
(
wsId
,
cellName
.
replace
(
/
\$
/g
,
""
),
wsR
[
j
].
Id
,
_cell
);
}
}
else
wb
.
dependencyFormulas
.
addEdge
(
wsId
,
cellName
.
replace
(
/
\$
/g
,
""
),
wsR
[
j
].
Id
,
_cell
);
}
}
}
}
}
}
return
this
.
value
;
return
this
.
value
;
};
};
cOFFSET
.
prototype
.
getInfo
=
function
()
{
cOFFSET
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( reference , rows , cols [ , [ height ] [ , [ width ] ] ] )
"
args
:
"
( reference , rows , cols [ , [ height ] [ , [ width ] ] ] )
"
};
};
};
};
function
cROW
()
{
// cBaseFunction.call( this, "ROW" );
// this.setArgumentsMin( 0 );
// this.setArgumentsMax( 1 );
/** @constructor */
function
cROW
()
{
this
.
name
=
"
ROW
"
;
this
.
name
=
"
ROW
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -1167,52 +1061,46 @@ function cROW() {
...
@@ -1167,52 +1061,46 @@ function cROW() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
1
;
this
.
argumentsMax
=
1
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cROW
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cROW
.
prototype
.
Calculate
=
function
(
arg
)
{
cROW
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cROW
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
;
var
arg0
;
if
(
this
.
argumentsCurrent
==
0
)
{
if
(
this
.
argumentsCurrent
==
0
)
{
arg0
=
arguments
[
1
];
arg0
=
arguments
[
1
];
return
this
.
value
=
new
cNumber
(
arg0
.
getFirst
().
getRow
()
);
return
this
.
value
=
new
cNumber
(
arg0
.
getFirst
().
getRow
()
);
}
}
arg0
=
arg
[
0
];
arg0
=
arg
[
0
];
if
(
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
||
arg0
instanceof
cArea
)
{
if
(
cElementType
.
cell
===
arg0
.
type
||
cElementType
.
cell3D
===
arg0
.
type
||
cElementType
.
cellsRange
===
arg0
.
type
)
{
var
range
=
arg0
.
getRange
();
var
range
=
arg0
.
getRange
();
if
(
range
)
if
(
range
)
{
return
this
.
value
=
new
cNumber
(
range
.
getFirst
().
getRow
()
);
return
this
.
value
=
new
cNumber
(
range
.
getFirst
().
getRow
()
);
else
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
if
(
arg0
instanceof
cArea3D
)
{
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
var
r
=
arg0
.
getRange
();
var
r
=
arg0
.
getRange
();
if
(
r
&&
r
[
0
]
&&
r
[
0
].
getFirst
()
)
{
if
(
r
&&
r
[
0
]
&&
r
[
0
].
getFirst
())
{
return
this
.
value
=
new
cNumber
(
r
[
0
].
getFirst
().
getRow
()
);
return
this
.
value
=
new
cNumber
(
r
[
0
].
getFirst
().
getRow
());
}
}
else
{
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
else
};
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
cROW
.
prototype
.
getInfo
=
function
()
{
};
cROW
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( [ reference ] )
"
args
:
"
( [ reference ] )
"
};
};
};
};
function
cROWS
()
{
// cBaseFunction.call( this, "ROWS" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 1 );
/** @constructor */
function
cROWS
()
{
this
.
name
=
"
ROWS
"
;
this
.
name
=
"
ROWS
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -1220,49 +1108,47 @@ function cROWS() {
...
@@ -1220,49 +1108,47 @@ function cROWS() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
1
;
this
.
argumentsMax
=
1
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
}
cROWS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cROWS
.
prototype
.
Calculate
=
function
(
arg
)
{
cROWS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cROWS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
];
var
arg0
=
arg
[
0
];
if
(
arg0
instanceof
cArray
)
{
if
(
cElementType
.
array
===
arg0
.
type
)
{
return
this
.
value
=
new
cNumber
(
arg0
.
getRowCount
()
);
return
this
.
value
=
new
cNumber
(
arg0
.
getRowCount
()
);
}
}
else
if
(
cElementType
.
cellsRange
===
arg0
.
type
||
cElementType
.
cell
===
arg0
.
type
||
else
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
)
{
cElementType
.
cell3D
===
arg0
.
type
)
{
var
range
=
arg0
.
getRange
();
var
range
=
arg0
.
getRange
();
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
.
getBBox
().
r1
-
range
.
getBBox
().
r2
)
+
1
);
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
.
getBBox
().
r1
-
range
.
getBBox
().
r2
)
+
1
);
}
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
else
if
(
arg0
instanceof
cArea3D
)
{
var
range
=
arg0
.
getRange
();
var
range
=
arg0
.
getRange
();
if
(
range
.
length
>
1
)
if
(
range
.
length
>
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
[
0
].
getBBox
().
r1
-
range
[
0
].
getBBox
().
r2
)
+
1
);
return
this
.
value
=
new
cNumber
(
Math
.
abs
(
range
[
0
].
getBBox
().
r1
-
range
[
0
].
getBBox
().
r2
)
+
1
);
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
}
else
};
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
cROWS
.
prototype
.
getInfo
=
function
()
{
};
cROWS
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( array )
"
args
:
"
( array )
"
};
};
};
};
function
cRTD
()
{
cBaseFunction
.
call
(
this
,
"
RTD
"
);
}
cRTD
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
/** @constructor */
function
cRTD
()
{
cBaseFunction
.
call
(
this
,
"
RTD
"
);
}
function
cTRANSPOSE
()
{
cRTD
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
// cBaseFunction.call( this, "TRANSPOSE" );
/** @constructor */
function
cTRANSPOSE
()
{
this
.
name
=
"
TRANSPOSE
"
;
this
.
name
=
"
TRANSPOSE
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -1270,158 +1156,138 @@ function cTRANSPOSE() {
...
@@ -1270,158 +1156,138 @@ function cTRANSPOSE() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
1
;
this
.
argumentsMax
=
1
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
noneFormat
;
this
.
numFormat
=
this
.
formatType
.
noneFormat
;
}
}
cTRANSPOSE
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cTRANSPOSE
.
prototype
.
Calculate
=
function
(
arg
)
{
cTRANSPOSE
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cTRANSPOSE
.
prototype
.
Calculate
=
function
(
arg
)
{
function
TransposeMatrix
(
A
)
{
function
TransposeMatrix
(
A
)
{
var
tMatrix
=
[],
res
=
new
cArray
();
var
tMatrix
=
[],
res
=
new
cArray
();
for
(
var
i
=
0
;
i
<
A
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
A
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
A
[
i
].
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
A
[
i
].
length
;
j
++
)
{
if
(
!
tMatrix
[
j
]
)
tMatrix
[
j
]
=
[];
if
(
!
tMatrix
[
j
])
{
tMatrix
[
j
]
=
[];
}
tMatrix
[
j
][
i
]
=
A
[
i
][
j
];
tMatrix
[
j
][
i
]
=
A
[
i
][
j
];
}
}
}
}
res
.
fillFromArray
(
tMatrix
);
res
.
fillFromArray
(
tMatrix
);
return
res
;
return
res
;
}
}
var
arg0
=
arg
[
0
];
var
arg0
=
arg
[
0
];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArray
)
{
if
(
cElementType
.
cellsRange
===
arg0
.
type
||
cElementType
.
array
===
arg0
.
type
)
{
arg0
=
arg0
.
getMatrix
();
arg0
=
arg0
.
getMatrix
();
}
}
else
if
(
cElementType
.
number
===
arg0
.
type
||
cElementType
.
string
===
arg0
.
type
||
else
if
(
arg0
instanceof
cNumber
||
arg0
instanceof
cString
||
arg0
instanceof
cBool
||
arg0
instanceof
cRef
||
arg0
instanceof
cRef3D
)
{
cElementType
.
bool
===
arg0
.
type
||
cElementType
.
cell
===
arg0
.
type
||
cElementType
.
cell3D
===
arg0
.
type
)
{
return
this
.
value
=
arg0
.
getValue
();
return
this
.
value
=
arg0
.
getValue
();
}
}
else
if
(
cElementType
.
error
===
arg0
.
type
)
{
else
if
(
arg0
instanceof
cError
)
{
return
this
.
value
=
arg0
;
return
this
.
value
=
arg0
;
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
else
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
TransposeMatrix
(
arg0
);
return
this
.
value
=
TransposeMatrix
(
arg0
);
};
};
cTRANSPOSE
.
prototype
.
getInfo
=
function
()
{
cTRANSPOSE
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( array )
"
args
:
"
( array )
"
};
};
};
};
function
VHLOOKUPCache
(
bHor
)
{
/** @constructor */
function
VHLOOKUPCache
(
bHor
)
{
this
.
cacheId
=
{};
this
.
cacheId
=
{};
this
.
cacheRanges
=
{};
this
.
cacheRanges
=
{};
this
.
bHor
=
bHor
;
this
.
bHor
=
bHor
;
}
}
VHLOOKUPCache
.
prototype
.
get
=
function
(
range
,
valueForSearching
,
isValueString
,
arg3Value
)
{
VHLOOKUPCache
.
prototype
.
get
=
function
(
range
,
valueForSearching
,
arg3Value
)
{
var
res
,
var
res
,
_this
=
this
,
wsId
=
range
.
getWorksheet
().
getId
(),
sRangeName
=
wsId
+
g_cCharDelimiter
+
_this
=
this
,
range
.
getName
(),
cacheElem
=
this
.
cacheId
[
sRangeName
];
wsId
=
range
.
getWorksheet
().
getId
(),
if
(
null
==
cacheElem
)
{
sRangeName
=
wsId
+
g_cCharDelimiter
+
range
.
getName
(),
cacheElem
=
{
elements
:
[],
results
:
{}};
cacheElem
=
this
.
cacheId
[
sRangeName
];
range
.
_foreachNoEmpty
(
function
(
cell
,
r
,
c
)
{
if
(
null
==
cacheElem
)
{
var
v
=
cell
.
getValueWithoutFormat
();
cacheElem
=
{
id
:
sRangeName
,
foreachArray
:[],
results
:{}};
cacheElem
.
elements
.
push
({
v
:
v
,
i
:
(
_this
.
bHor
?
c
:
r
)});
range
.
_foreachNoEmpty
(
/*func for cell in col*/
function
(
cell
,
r
,
c
,
r1
,
c1
)
{
});
var
cv
=
cell
.
getValueWithoutFormat
();
if
(
_this
.
bHor
)
cacheElem
.
foreachArray
.
push
(
{
cv
:
cv
,
cvType
:
checkTypeCell
(
cv
),
index
:
c
,
indexStart
:
c1
}
);
else
cacheElem
.
foreachArray
.
push
(
{
cv
:
cv
,
cvType
:
checkTypeCell
(
cv
),
index
:
r
,
indexStart
:
r1
}
);
}
);
this
.
cacheId
[
sRangeName
]
=
cacheElem
;
this
.
cacheId
[
sRangeName
]
=
cacheElem
;
var
cacheRange
=
this
.
cacheRanges
[
wsId
];
var
cacheRange
=
this
.
cacheRanges
[
wsId
];
if
(
null
==
cacheRange
)
{
if
(
null
==
cacheRange
)
{
cacheRange
=
new
AscCommonExcel
.
RangeDataManager
(
null
);
cacheRange
=
new
AscCommonExcel
.
RangeDataManager
(
null
);
this
.
cacheRanges
[
wsId
]
=
cacheRange
;
this
.
cacheRanges
[
wsId
]
=
cacheRange
;
}
}
cacheRange
.
add
(
range
.
getBBox0
(),
cacheElem
);
cacheRange
.
add
(
range
.
getBBox0
(),
cacheElem
);
}
}
var
sInputKey
=
valueForSearching
+
g_cCharDelimiter
+
isValueStr
ing
+
g_cCharDelimiter
+
arg3Value
;
var
sInputKey
=
valueForSearch
ing
+
g_cCharDelimiter
+
arg3Value
;
res
=
cacheElem
.
results
[
sInputKey
];
res
=
cacheElem
.
results
[
sInputKey
];
if
(
null
==
res
)
{
if
(
null
==
res
)
{
res
=
this
.
_calculate
(
cacheElem
.
foreachArray
,
valueForSearching
,
isValueString
,
arg3Value
);
res
=
this
.
_calculate
(
cacheElem
.
elements
,
valueForSearching
,
arg3Value
);
cacheElem
.
results
[
sInputKey
]
=
res
;
cacheElem
.
results
[
sInputKey
]
=
res
;
}
}
return
res
;
return
res
;
};
};
VHLOOKUPCache
.
prototype
.
_calculate
=
function
(
cacheArray
,
valueForSearching
,
isValueString
,
arg3Value
)
{
VHLOOKUPCache
.
prototype
.
_calculate
=
function
(
cacheArray
,
valueForSearching
,
lookup
)
{
var
res
=
{
min
:
undefined
,
index
:
-
1
},
found
=
false
,
regexp
=
null
;
var
res
=
-
1
,
i
=
0
,
j
,
length
=
cacheArray
.
length
,
k
,
elem
,
val
;
for
(
var
i
=
0
,
length
=
cacheArray
.
length
;
i
<
length
;
i
++
)
{
var
cache
=
cacheArray
[
i
];
if
(
''
===
valueForSearching
&&
0
!==
length
)
{
var
cv
=
cache
.
cv
;
return
cacheArray
[
0
].
i
;
var
index
=
cache
.
index
;
}
var
indexStart
=
cache
.
indexStart
;
if
(
lookup
)
{
var
cvType
=
cache
.
cvType
;
j
=
length
-
1
;
if
(
index
==
indexStart
)
while
(
i
<=
j
)
{
res
.
min
=
cv
;
k
=
Math
.
floor
((
i
+
j
)
/
2
);
else
if
(
res
.
min
>
cv
)
{
elem
=
cacheArray
[
k
];
res
.
min
=
cv
;
val
=
elem
.
v
;
}
if
(
valueForSearching
==
val
)
{
if
(
arg3Value
==
true
)
{
return
elem
.
i
;
if
(
isValueString
)
{
}
else
if
(
valueForSearching
<
val
)
{
if
(
cvType
instanceof
cString
)
{
j
=
k
-
1
;
if
(
valueForSearching
.
localeCompare
(
cvType
.
getValue
()
)
==
0
)
{
}
else
{
res
.
index
=
index
;
i
=
k
+
1
;
found
=
true
;
}
}
}
else
if
(
valueForSearching
.
localeCompare
(
cvType
.
getValue
()
)
==
1
&&
!
found
)
{
res
=
Math
.
min
(
i
,
j
);
res
.
index
=
index
;
res
=
-
1
===
res
?
res
:
cacheArray
[
res
].
i
;
}
}
else
{
}
// Exact value
}
for
(;
i
<
length
;
i
++
)
{
else
if
(
valueForSearching
==
cv
)
{
elem
=
cacheArray
[
i
];
res
.
index
=
index
;
val
=
elem
.
v
;
found
=
true
;
if
(
valueForSearching
==
val
)
{
}
return
elem
.
i
;
else
if
(
valueForSearching
>
cv
&&
!
found
)
{
res
.
index
=
index
;
}
}
else
{
if
(
isValueString
)
{
if
(
null
==
regexp
)
regexp
=
searchRegExp
(
valueForSearching
);
if
(
regexp
.
test
(
cv
)
)
res
.
index
=
index
;
}
else
if
(
valueForSearching
==
cv
)
{
res
.
index
=
index
;
}
}
}
}
}
}
return
res
;
return
res
;
};
};
VHLOOKUPCache
.
prototype
.
remove
=
function
(
cell
)
{
VHLOOKUPCache
.
prototype
.
remove
=
function
(
cell
)
{
var
wsId
=
cell
.
ws
.
getId
();
var
wsId
=
cell
.
ws
.
getId
();
var
cacheRange
=
this
.
cacheRanges
[
wsId
];
var
cacheRange
=
this
.
cacheRanges
[
wsId
];
if
(
null
!=
cacheRange
)
{
if
(
null
!=
cacheRange
)
{
var
oGetRes
=
cacheRange
.
get
(
new
Asc
.
Range
(
cell
.
nCol
,
cell
.
nRow
,
cell
.
nCol
,
cell
.
nRow
)
);
var
oGetRes
=
cacheRange
.
get
(
new
Asc
.
Range
(
cell
.
nCol
,
cell
.
nRow
,
cell
.
nCol
,
cell
.
nRow
)
);
for
(
var
i
=
0
,
length
=
oGetRes
.
all
.
length
;
i
<
length
;
++
i
)
{
for
(
var
i
=
0
,
length
=
oGetRes
.
all
.
length
;
i
<
length
;
++
i
)
{
var
elem
=
oGetRes
.
all
[
i
];
var
elem
=
oGetRes
.
all
[
i
];
elem
.
data
.
results
=
{};
elem
.
data
.
results
=
{};
}
}
}
}
};
};
VHLOOKUPCache
.
prototype
.
clean
=
function
()
{
VHLOOKUPCache
.
prototype
.
clean
=
function
()
{
this
.
cacheId
=
{};
this
.
cacheId
=
{};
this
.
cacheRanges
=
{};
this
.
cacheRanges
=
{};
};
};
function
cVLOOKUP
()
{
// cBaseFunction.call( this, "VLOOKUP" );
/** @constructor */
function
cVLOOKUP
()
{
this
.
name
=
"
VLOOKUP
"
;
this
.
name
=
"
VLOOKUP
"
;
this
.
type
=
cElementType
.
func
;
this
.
type
=
cElementType
.
func
;
this
.
value
=
null
;
this
.
value
=
null
;
...
@@ -1429,240 +1295,118 @@ function cVLOOKUP() {
...
@@ -1429,240 +1295,118 @@ function cVLOOKUP() {
this
.
argumentsCurrent
=
0
;
this
.
argumentsCurrent
=
0
;
this
.
argumentsMax
=
4
;
this
.
argumentsMax
=
4
;
this
.
formatType
=
{
this
.
formatType
=
{
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
def
:
-
1
,
//подразумевается формат первой ячейки входящей в формулу.
noneFormat
:
-
2
noneFormat
:
-
2
};
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
numFormat
=
this
.
formatType
.
def
;
}
// this.setArgumentsMin( 3 );
cVLOOKUP
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
// this.setArgumentsMax( 4 );
cVLOOKUP
.
prototype
.
Calculate
=
function
(
arg
)
{
}
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
var
arg3
=
this
.
argumentsCurrent
==
4
?
arg
[
3
].
tocBool
().
value
:
true
;
cVLOOKUP
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cVLOOKUP
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
],
arg3
=
this
.
argumentsCurrent
==
4
?
arg
[
3
].
tocBool
()
:
new
cBool
(
true
);
var
numberCol
=
arg2
.
getValue
()
-
1
,
valueForSearching
,
resR
=
-
1
,
min
,
regexp
;
var
numberCol
=
arg2
.
getValue
()
-
1
,
valueForSearching
,
resR
=
-
1
,
min
,
regexp
;
if
(
isNaN
(
numberCol
)
)
if
(
isNaN
(
numberCol
))
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
if
(
numberCol
<
0
)
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
if
(
arg0
instanceof
cRef
)
{
arg0
=
arg0
.
getValue
()
}
if
(
arg0
instanceof
cString
)
{
valueForSearching
=
arg0
.
getValue
();
}
else
if
(
arg0
instanceof
cError
)
return
this
.
value
=
arg0
;
else
{
valueForSearching
=
arg0
.
getValue
();
}
}
if
(
numberCol
<
0
)
{
var
found
=
false
,
bb
;
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
if
(
arg1
instanceof
cRef
||
arg1
instanceof
cRef3D
)
{
var
range
=
arg1
.
getRange
(),
ws
=
arg1
.
getWS
();
bb
=
range
.
getBBox0
();
if
(
numberCol
>
bb
.
c2
-
bb
.
c1
)
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r2
,
bb
.
c1
);
var
oCache
=
g_oVLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg0
instanceof
cString
,
arg3
.
value
);
if
(
oCache
)
{
resR
=
oCache
.
index
;
min
=
oCache
.
min
;
}
}
else
if
(
arg1
instanceof
cArea
)
{
var
range
=
arg1
.
getRange
(),
ws
=
arg1
.
getWS
();
bb
=
range
.
getBBox0
();
if
(
numberCol
>
bb
.
c2
-
bb
.
c1
)
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r2
,
bb
.
c1
);
var
oCache
=
g_oVLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg0
instanceof
cString
,
arg3
.
value
);
if
(
oCache
)
{
resR
=
oCache
.
index
;
min
=
oCache
.
min
;
}
/*var matrix = arg1.getMatrix();
for(var matrixHeight = 0; matrixHeight<matrix.length; matrixHeight++){
for(var matrixWidth = 0; matrixWidth<1; matrixWidth++){
var cvType = matrix[matrixHeight][matrixWidth], cv = cvType.getValue();
if ( matrixHeight == 0 )
min = cv;
else if( min > cv ){
min = cv;
}
if ( arg3.value == true ) {
if ( arg0 instanceof cString ) {
if ( cvType instanceof cString ){
if( valueForSearching.localeCompare( cvType.getValue() ) == 0 ){
resR = matrixHeight+bb.r1;
found = true;
}
else if( valueForSearching.localeCompare( cvType.getValue() ) == 1 && !found ){
resR = matrixHeight+bb.r1;
}
}
}
else if ( valueForSearching == cv ) {
resR = matrixHeight+bb.r1;
found = true;
}
else if ( valueForSearching > cv && !found ) {
resR = matrixHeight+bb.r1;
}
}
else {
if ( arg0 instanceof cString ) {
if ( regexp.test( cv ) )
resR = matrixHeight+bb.r1;
}
else if ( valueForSearching == cv ) {
resR = matrixHeight+bb.r1;
}
}
//f( matrix[matrixHeight][matrixWidth], matrixHeight+bb.r1, matrixWidth+bb.c1, bb.r1, bb.c1 )
}
}
}*/
}
else
if
(
arg1
instanceof
cArea3D
)
{
var
range
=
arg1
.
getRange
()[
0
],
ws
=
arg1
.
getWS
();
bb
=
range
.
getBBox0
();
if
(
numberCol
>
bb
.
c2
-
bb
.
c1
)
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
/*var matrix = arg1.getMatrix()[0]
for(var matrixHeight = 0; matrixHeight<matrix.length; matrixHeight++){
if
(
cElementType
.
cell3D
===
arg0
.
type
||
cElementType
.
cell
===
arg0
.
type
)
{
for(var matrixWidth = 0; matrixWidth<1; matrixWidth++){
arg0
=
arg0
.
getValue
();
var cvType = matrix[matrixHeight][matrixWidth], cv = cvType.getValue();
if ( matrixHeight == 0 )
min = cv;
else if( min > cv ){
min = cv;
}
if ( arg3.value == true ) {
if ( arg0 instanceof cString ) {
if ( cvType instanceof cString ){
if( valueForSearching.localeCompare( cvType.getValue() ) == 0 ){
resR = matrixHeight+bb.r1;
found = true;
}
else if( valueForSearching.localeCompare( cvType.getValue() ) == 1 && !found ){
resR = matrixHeight+bb.r1;
}
}
}
else if ( valueForSearching == cv ) {
resR = matrixHeight+bb.r1;
found = true;
}
else if ( valueForSearching > cv && !found ) {
resR = matrixHeight+bb.r1;
}
}
else {
if ( arg0 instanceof cString ) {
if ( regexp.test( cv ) )
resR = matrixHeight+bb.r1;
}
else if ( valueForSearching == cv ) {
resR = matrixHeight+bb.r1;
}
}
}
//f( matrix[matrixHeight][matrixWidth], matrixHeight+bb.r1, matrixWidth+bb.c1, bb.r1, bb.c1 )
}
}*/
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r2
,
bb
.
c1
);
if
(
cElementType
.
error
===
arg0
.
type
)
{
var
oCache
=
g_oVLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg0
instanceof
cString
,
arg3
.
value
);
return
this
.
value
=
arg0
;
if
(
oCache
)
{
}
else
{
resR
=
oCache
.
index
;
valueForSearching
=
arg0
.
getValue
();
min
=
oCache
.
min
;
}
}
var
found
=
false
;
if
(
cElementType
.
array
===
arg1
.
type
)
{
// ToDo
if
(
cElementType
.
string
===
arg0
.
type
)
{
regexp
=
searchRegExp
(
valueForSearching
);
}
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
.
foreach
(
function
(
elem
,
r
)
{
if
(
arg0
instanceof
cString
)
if
(
r
==
0
)
{
regexp
=
searchRegExp
(
valueForSearching
);
arg1
.
foreach
(
function
(
elem
,
r
)
{
if
(
r
==
0
)
min
=
elem
.
getValue
();
min
=
elem
.
getValue
();
}
if
(
arg3
.
value
==
true
)
{
if
(
arg3
)
{
if
(
valueForSearching
==
elem
.
getValue
()
)
{
if
(
valueForSearching
==
elem
.
getValue
()
)
{
resR
=
r
;
resR
=
r
;
found
=
true
;
found
=
true
;
}
}
else
if
(
valueForSearching
>
elem
.
getValue
()
&&
!
found
)
{
else
if
(
valueForSearching
>
elem
.
getValue
()
&&
!
found
)
{
resR
=
r
;
resR
=
r
;
}
}
}
}
else
{
else
{
if
(
cElementType
.
string
===
arg0
.
type
)
{
if
(
arg0
instanceof
cString
)
{
if
(
regexp
.
test
(
elem
.
getValue
()))
{
if
(
regexp
.
test
(
elem
.
getValue
()
)
)
resR
=
r
;
resR
=
r
;
}
}
else
if
(
valueForSearching
==
elem
.
getValue
()
)
{
}
else
if
(
valueForSearching
==
elem
.
getValue
()
)
{
resR
=
r
;
resR
=
r
;
}
}
}
}
min
=
Math
.
min
(
min
,
elem
.
getValue
()
);
min
=
Math
.
min
(
min
,
elem
.
getValue
()
);
}
);
}
);
if
(
min
>
valueForSearching
)
{
if
(
min
>
valueForSearching
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
if
(
resR
==
-
1
)
{
if
(
resR
==
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
if
(
numberCol
>
arg1
.
getCountElementInRow
()
-
1
)
{
if
(
numberCol
>
arg1
.
getCountElementInRow
()
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
return
this
.
value
=
arg1
.
getElementRowCol
(
resR
,
numberCol
);
return
this
.
value
=
arg1
.
getElementRowCol
(
resR
,
numberCol
);
}
}
if
(
min
>
valueForSearching
)
{
var
range
;
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
if
(
cElementType
.
cell
===
arg1
.
type
||
cElementType
.
cell3D
===
arg1
.
type
||
cElementType
.
cellsRange
===
arg1
.
type
)
{
range
=
arg1
.
getRange
();
}
else
if
(
cElementType
.
cellsRange3D
===
arg1
.
type
)
{
range
=
arg1
.
getRange
()[
0
];
}
}
if
(
!
range
)
{
if
(
resR
==
-
1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
}
var
c
=
new
CellAddress
(
resR
,
bb
.
c1
+
numberCol
,
0
);
var
bb
=
range
.
getBBox0
();
if
(
numberCol
>
bb
.
c2
-
bb
.
c1
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
bad_reference
);
}
var
ws
=
arg1
.
getWS
();
var
oSearchRange
=
ws
.
getRange3
(
bb
.
r1
,
bb
.
c1
,
bb
.
r2
,
bb
.
c1
);
var
v
=
arg1
.
getWS
().
_getCellNoEmpty
(
c
.
getRow0
(),
c
.
getCol0
()
);
resR
=
g_oVLOOKUPCache
.
get
(
oSearchRange
,
valueForSearching
,
arg3
);
if
(
v
)
if
(
-
1
===
resR
)
{
v
=
v
.
getValueWithoutFormat
();
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
else
}
v
=
""
;
return
this
.
value
=
checkTypeCell
(
v
);
var
v
=
arg1
.
getWS
().
_getCellNoEmpty
(
resR
,
bb
.
c1
+
numberCol
);
};
return
this
.
value
=
checkTypeCell2
(
v
);
cVLOOKUP
.
prototype
.
getInfo
=
function
()
{
};
cVLOOKUP
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( lookup-value , table-array , col-index-num [ , [ range-lookup-flag ] ] )
"
args
:
"
( lookup-value , table-array , col-index-num [ , [ range-lookup-flag ] ] )
"
};
};
};
};
var
g_oVLOOKUPCache
=
new
VHLOOKUPCache
(
false
);
var
g_oVLOOKUPCache
=
new
VHLOOKUPCache
(
false
);
var
g_oHLOOKUPCache
=
new
VHLOOKUPCache
(
true
);
var
g_oHLOOKUPCache
=
new
VHLOOKUPCache
(
true
);
//----------------------------------------------------------export----------------------------------------------------
//----------------------------------------------------------export----------------------------------------------------
window
[
'
AscCommonExcel
'
]
=
window
[
'
AscCommonExcel
'
]
||
{};
window
[
'
AscCommonExcel
'
]
=
window
[
'
AscCommonExcel
'
]
||
{};
window
[
'
AscCommonExcel
'
].
g_oVLOOKUPCache
=
g_oVLOOKUPCache
;
window
[
'
AscCommonExcel
'
].
g_oVLOOKUPCache
=
g_oVLOOKUPCache
;
window
[
'
AscCommonExcel
'
].
g_oHLOOKUPCache
=
g_oHLOOKUPCache
;
window
[
'
AscCommonExcel
'
].
g_oHLOOKUPCache
=
g_oHLOOKUPCache
;
})(
window
);
})(
window
);
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