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.cjs.js CHANGED
@@ -176,6 +176,32 @@ const SheetUtils = {
176
176
  allCellObjs = rapidUtils.orderByJson(allCellObjs, !isMulColOrder ? ['row', 'col'] : ['col', 'row'], ['asc', 'asc']);
177
177
  return allCellObjs;
178
178
  },
179
+ /**
180
+ * 根据单元格范围字符串获取单元格对象集合
181
+ * @param sheet 工作表实例
182
+ * @param formulaStr 单元格范围字符串(如:B2:C3、Sheet1!B2:C3、=Sheet1!B2:C3、=Sheet1!B2:C3,Sheet1!B5:D6,Sheet1!B8:C9)
183
+ * 返回数组集合,格式如:[{ col: 0, row: 0, rowCount: 1, colCount: 1 }]
184
+ */
185
+ getAllCellObjsByRangeStr: (sheet, formulaStr) => {
186
+ // 得到所有的单元格坐标对象集合,格式如:[{ row: 0, col: 0, rowCount: 1, colCount: 1 }]
187
+ let allCellObjs = [];
188
+ // 单元格选择的范围为多个范围
189
+ if (formulaStr.indexOf(',') > -1) {
190
+ // 将多范围字符串分离为单个范围的数组
191
+ const formulaStrArr = formulaStr.split(',');
192
+ formulaStrArr.forEach((item, index) => {
193
+ // 得到每个范围的字符串
194
+ const rangeStr = item.substring(item.lastIndexOf('!') + 1);
195
+ allCellObjs.push(sheet.getRange(rangeStr));
196
+ });
197
+ }
198
+ // 只有一个范围
199
+ else {
200
+ // 直接将范围字符串传给sheet.getRange即可
201
+ allCellObjs.push(sheet.getRange(formulaStr));
202
+ }
203
+ return allCellObjs;
204
+ },
179
205
  /**
180
206
  * 获取某工作表中所有的单元格坐标对象集合
181
207
  * @param sheet 工作表实例
@@ -18995,6 +19021,47 @@ const FormulaUtils = {
18995
19021
  return bzc;
18996
19022
  },
18997
19023
  },
19024
+ {
19025
+ funName: 'YJTREND',
19026
+ funDesc: '返回线性回归拟合线的一组纵坐标值(y值)',
19027
+ funDefaultVal: null,
19028
+ isAcceptArea: true,
19029
+ funParams: [
19030
+ {
19031
+ name: '已知的因变量值(y值)数组',
19032
+ repeatable: false,
19033
+ optional: false,
19034
+ },
19035
+ {
19036
+ name: '已知的自变量值(x值)数组',
19037
+ repeatable: false,
19038
+ optional: false,
19039
+ },
19040
+ {
19041
+ name: '希望预测y值的新x值',
19042
+ repeatable: false,
19043
+ optional: false,
19044
+ },
19045
+ ],
19046
+ funCallback: (spread, sheet, retData) => {
19047
+ //如果传递的参数小于3个,则返回空字符串
19048
+ if (retData.allCellValsEw.length < 3) {
19049
+ return '';
19050
+ }
19051
+ 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];
19052
+ if (Array.isArray(x) && x.length > 0) {
19053
+ x = Number(x[0]);
19054
+ }
19055
+ else {
19056
+ x = Number(x);
19057
+ }
19058
+ console.log(111, retData);
19059
+ console.log(222, xData);
19060
+ console.log(333, yData);
19061
+ console.log(444, x);
19062
+ return 'OK';
19063
+ },
19064
+ },
18998
19065
  ],
18999
19066
  };
19000
19067