rapid-spreadjs 1.0.48 → 1.0.50

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
@@ -154,6 +154,32 @@ const SheetUtils = {
154
154
  allCellObjs = orderByJson(allCellObjs, !isMulColOrder ? ['row', 'col'] : ['col', 'row'], ['asc', 'asc']);
155
155
  return allCellObjs;
156
156
  },
157
+ /**
158
+ * 根据单元格范围字符串获取单元格对象集合
159
+ * @param sheet 工作表实例
160
+ * @param formulaStr 单元格范围字符串(如:B2:C3、Sheet1!B2:C3、=Sheet1!B2:C3、=Sheet1!B2:C3,Sheet1!B5:D6,Sheet1!B8:C9)
161
+ * 返回数组集合,格式如:[{ col: 0, row: 0, rowCount: 1, colCount: 1 }]
162
+ */
163
+ getAllCellObjsByRangeStr: (sheet, formulaStr) => {
164
+ // 得到所有的单元格坐标对象集合,格式如:[{ row: 0, col: 0, rowCount: 1, colCount: 1 }]
165
+ let allCellObjs = [];
166
+ // 单元格选择的范围为多个范围
167
+ if (formulaStr.indexOf(',') > -1) {
168
+ // 将多范围字符串分离为单个范围的数组
169
+ const formulaStrArr = formulaStr.split(',');
170
+ formulaStrArr.forEach((item, index) => {
171
+ // 得到每个范围的字符串
172
+ const rangeStr = item.substring(item.lastIndexOf('!') + 1);
173
+ allCellObjs.push(sheet.getRange(rangeStr));
174
+ });
175
+ }
176
+ // 只有一个范围
177
+ else {
178
+ // 直接将范围字符串传给sheet.getRange即可
179
+ allCellObjs.push(sheet.getRange(formulaStr));
180
+ }
181
+ return allCellObjs;
182
+ },
157
183
  /**
158
184
  * 获取某工作表中所有的单元格坐标对象集合
159
185
  * @param sheet 工作表实例
@@ -18973,6 +18999,47 @@ const FormulaUtils = {
18973
18999
  return bzc;
18974
19000
  },
18975
19001
  },
19002
+ {
19003
+ funName: 'YJTREND',
19004
+ funDesc: '返回线性回归拟合线的一组纵坐标值(y值)',
19005
+ funDefaultVal: null,
19006
+ isAcceptArea: true,
19007
+ funParams: [
19008
+ {
19009
+ name: '已知的因变量值(y值)数组',
19010
+ repeatable: false,
19011
+ optional: false,
19012
+ },
19013
+ {
19014
+ name: '已知的自变量值(x值)数组',
19015
+ repeatable: false,
19016
+ optional: false,
19017
+ },
19018
+ {
19019
+ name: '希望预测y值的新x值',
19020
+ repeatable: false,
19021
+ optional: false,
19022
+ },
19023
+ ],
19024
+ funCallback: (spread, sheet, retData) => {
19025
+ //如果传递的参数小于3个,则返回空字符串
19026
+ if (retData.allCellValsEw.length < 3) {
19027
+ return '';
19028
+ }
19029
+ let xData = FormulaUtils.commFun.convertToInt(retData.allCellValsEw[0].filter((item) => FormulaUtils.commFun.isNumber(item))), yData = FormulaUtils.commFun.convertToInt(retData.allCellValsEw[1].filter((item) => FormulaUtils.commFun.isNumber(item))), x = retData.allCellValsEw[2];
19030
+ if (Array.isArray(x) && x.length > 0) {
19031
+ x = Number(x[0]);
19032
+ }
19033
+ else {
19034
+ x = Number(x);
19035
+ }
19036
+ console.log(111, retData);
19037
+ console.log(222, xData);
19038
+ console.log(333, yData);
19039
+ console.log(444, x);
19040
+ return 'OK';
19041
+ },
19042
+ },
18976
19043
  ],
18977
19044
  };
18978
19045