Commit b0742732 authored by GoshaZotov's avatar GoshaZotov

for TEXTJOIN formula

parent 75d54d01
......@@ -2468,6 +2468,34 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
}
return null;
};
cBaseFunction.prototype._getOneDimensionalArray = function (arg, type) {
var res = [];
var getValue = function(curArg){
if(undefined === type || cElementType.string === type){
return curArg.tocString().getValue();
}else if( cElementType.number === type){
return curArg.tocNumber().getValue();
}
};
if (cElementType.cellsRange === arg.type || cElementType.cellsRange3D === arg.type) {
arg = arg.getMatrix();
for (var i = 0; i < arg.length; i++) {
for (var j = 0; j < arg[i].length; j++) {
res.push(getValue(arg[i][j]));
}
}
}else if(cElementType.array === arg.type){
arg.foreach(function (elem) {
res.push(getValue(elem));
})
}else{
res.push(getValue(arg));
}
return res;
};
/** @constructor */
function parentLeft() {
......
......@@ -1806,26 +1806,34 @@
cTEXTJOIN.prototype.isXLFN = true;
cTEXTJOIN.prototype.Calculate = function (arg) {
var oArguments = this._prepareArguments([arg[0], arg[1]], arguments[1], true);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocString();
argClone[1] = argClone[1].tocBool();
var argClone = [arg[0], arg[1]];
argClone[1] = arg[1].tocBool();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
var delimiter = argClone[0].toString();
var ignore_empty = argClone[1].toBool();
var delimiter = argClone[0];
var delimiterArr = this._getOneDimensionalArray(delimiter);
var delimiterIter = 0;
var concatString = function(string1, string2){
var res = string1;
var delimeterStr = string1 === "" ? "" : delimiter;
if("" === string2 && ignore_empty){
return res;
}
var isStartStr = string1 === "";
var delimeterStr = isStartStr ? "" : delimiterArr[delimiterIter];
if(undefined === delimeterStr){
delimiterIter = 0;
delimeterStr = delimiterArr[delimiterIter];
}
if(!isStartStr){
delimiterIter++;
}
res += delimeterStr + string2;
return res;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment