rapid-spreadjs 1.0.90 → 1.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -20033,6 +20033,11 @@ const FormulaUtils = {
20033
20033
  repeatable: false,
20034
20034
  optional: false,
20035
20035
  },
20036
+ {
20037
+ name: '是否返回符合或不符合结果的数量(传数字的1或0,0:不返回数量、1:返回数量),默认为:0',
20038
+ repeatable: false,
20039
+ optional: false,
20040
+ },
20036
20041
  ],
20037
20042
  funCallback: (spread, sheet, retData) => {
20038
20043
  // 如果传递的参数小于5个,则返回空字符串
@@ -20040,7 +20045,9 @@ const FormulaUtils = {
20040
20045
  if (retData.allCellValsEw.length < 5) {
20041
20046
  return '/';
20042
20047
  }
20043
- let array1 = retData.allCellValsEw[0], array2 = retData.allCellValsEw[1], operator = retData.allCellValsEw[2], value = retData.allCellValsEw[3], delimiter = retData.allCellValsEw[4], isOpposite = retData.allCellValsEw.length < 6 ? 0 : retData.allCellValsEw[5];
20048
+ let array1 = retData.allCellValsEw[0], array2 = retData.allCellValsEw[1], operator = retData.allCellValsEw[2], value = retData.allCellValsEw[3], delimiter = retData.allCellValsEw[4], isOpposite = retData.allCellValsEw.length < 6 ? 0 : retData.allCellValsEw[5],
20049
+ // 是否返回符合或不符合结果的数量(如最终符合或不符合的结果为“5,6,7”,并且isReturnCount=1,则返回数字3,否则返回“5,6,7”),默认为:0
20050
+ isReturnCount = retData.allCellValsEw.length < 7 ? 0 : retData.allCellValsEw[6];
20044
20051
  try {
20045
20052
  // 处理array1和array2的默认值
20046
20053
  if (array1 == null || array1 == undefined || (typeof array1 == 'string' && array1.trim().length == 0)) {
@@ -20055,7 +20062,7 @@ const FormulaUtils = {
20055
20062
  if (typeof array2 == 'string' && array2.trim().length > 0) {
20056
20063
  array2 = [array2];
20057
20064
  }
20058
- // 如果operator、value、delimiter、isOpposite为数组,则设置其取第一个值
20065
+ // 如果operator、value、delimiter、isOpposite、isReturnCount为数组,则设置其取第一个值
20059
20066
  if (Array.isArray(operator) && operator.length > 0) {
20060
20067
  operator = operator[0];
20061
20068
  }
@@ -20068,6 +20075,9 @@ const FormulaUtils = {
20068
20075
  if (Array.isArray(isOpposite) && isOpposite.length > 0) {
20069
20076
  isOpposite = isOpposite[0];
20070
20077
  }
20078
+ if (Array.isArray(isReturnCount) && isReturnCount.length > 0) {
20079
+ isReturnCount = isReturnCount[0];
20080
+ }
20071
20081
  // 设置isOpposite的默认值
20072
20082
  if (isOpposite == '1' || isOpposite == '0') {
20073
20083
  isOpposite = parseInt(isOpposite);
@@ -20075,6 +20085,13 @@ const FormulaUtils = {
20075
20085
  if (isOpposite != 0 && isOpposite != 1) {
20076
20086
  isOpposite = 0;
20077
20087
  }
20088
+ // 设置isReturnCount的默认值
20089
+ if (isReturnCount == '1' || isReturnCount == '0') {
20090
+ isReturnCount = parseInt(isReturnCount);
20091
+ }
20092
+ if (isReturnCount != 0 && isReturnCount != 1) {
20093
+ isReturnCount = 0;
20094
+ }
20078
20095
  // TODO:暂定此情况
20079
20096
  // 第一个参数是否为单值(array1为一个值的时候,此时array2的所有元素可能需要参与计算,满足要求的就返回array2中的值)
20080
20097
  const isSingleValue1 = array2.length > array1.length && array1.length == 1;
@@ -20179,8 +20196,8 @@ const FormulaUtils = {
20179
20196
  return '';
20180
20197
  })
20181
20198
  .filter((val) => val !== '' && val != '/' && val != 'null' && val != null && val != undefined); // 过滤空值
20182
- // 使用指定的分隔符连接结果[2,3,5](@ref)
20183
- return resultValues.join(delimiter);
20199
+ // 使用指定的分隔符连接结果[2,3,5]
20200
+ return isReturnCount == 1 ? resultValues.length : resultValues.join(delimiter);
20184
20201
  }
20185
20202
  catch (error) {
20186
20203
  // 任何错误都返回"/"