rapid-spreadjs 1.0.39 → 1.0.41

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
@@ -595,6 +595,58 @@ const SheetUtils = {
595
595
  // // 或者使用SpreadJS提供的方法rangeToFormula
596
596
  // return GC.Spread.Sheets.CalcEngine.rangeToFormula(cellRange);
597
597
  },
598
+ /**
599
+ * 获取工作表中所有纯值或公式单元格的范围选择字符串
600
+ * @param sheet 工作表对象
601
+ * @param isFormulaCells 是否获取公式单元格,默认为:false
602
+ */
603
+ getCellsRangeStr: (sheet, isFormulaCells = false) => {
604
+ const range = { row: 0, col: 1, rowCount: sheet.getRowCount(), colCount: 77 };
605
+ // 所有单元格对象集合
606
+ const allCells = SheetUtils.getAllCellObjsByRanges(sheet, [range]);
607
+ // 最终需要的单元格对象集合
608
+ let retCells = [];
609
+ // 遍历所有单元格
610
+ allCells.forEach((cell) => {
611
+ const value = sheet.getValue(cell.row, cell.col);
612
+ const formula = sheet.getFormula(cell.row, cell.col);
613
+ // 非公式+有值(非空) || 公式
614
+ if ((!isFormulaCells && !formula && value !== null && value !== undefined && value !== '') || (isFormulaCells && formula)) {
615
+ retCells.push(cell);
616
+ }
617
+ });
618
+ // 辅助函数:将列索引转为大写字母(如 0->A, 1->B, 26->AA)
619
+ const indexToAlpha = (index) => {
620
+ let alpha = '';
621
+ while (index >= 0) {
622
+ alpha = String.fromCharCode(65 + (index % 26)) + alpha;
623
+ index = Math.floor(index / 26) - 1;
624
+ if (index < 0)
625
+ break;
626
+ }
627
+ return alpha;
628
+ };
629
+ // Sheet名称
630
+ const sheetName = sheet.name();
631
+ // 处理每个单元格/区域
632
+ const cellStrings = retCells.map((cell) => {
633
+ // 起始列字母
634
+ const colAlpha = indexToAlpha(cell.col);
635
+ // 起始行号(从1计数)
636
+ const startRow = cell.row + 1;
637
+ // 合并单元格只返回左上角单元格
638
+ const isMerged = cell.rowCount > 1 || cell.colCount > 1;
639
+ // 处理区域范围(合并单元格只返回左上角)
640
+ if (isMerged) {
641
+ return `${sheetName}!${colAlpha}${startRow}`;
642
+ }
643
+ // 处理单单元格
644
+ else {
645
+ return `${sheetName}!${colAlpha}${startRow}`;
646
+ }
647
+ });
648
+ return '=' + cellStrings.join(',');
649
+ },
598
650
  };
599
651
 
600
652
  /**
@@ -627,6 +679,15 @@ const BusinessUtils = {
627
679
  sheet.suspendPaint();
628
680
  // 设置工作表行数为0
629
681
  sheet.setRowCount(0);
682
+ /**
683
+ * 设置单元格字体和大小
684
+ * @param row
685
+ * @param col
686
+ */
687
+ const setFontSizeFamily = (row, col) => {
688
+ sheet.getCell(row, col).fontFamily('宋体');
689
+ sheet.getCell(row, col).fontSize('9pt');
690
+ };
630
691
  for (let i = 0; i < testObjectAttrsChunk.length; i++) {
631
692
  const rowAttrArr = testObjectAttrsChunk[i];
632
693
  // 获取总行数
@@ -653,6 +714,8 @@ const BusinessUtils = {
653
714
  sheet.addSpan(totalRowCount, contentColStartIndex + titleCellColumnCount, 1, rowAttrArr.length > 1 ? titleCellValColumnCount : contentTotalColCount - titleCellColumnCount, gc.Spread.Sheets.SheetArea.viewport);
654
715
  sheet.setValue(totalRowCount, contentColStartIndex, rowAttrArr[0].title);
655
716
  sheet.setValue(totalRowCount, contentColStartIndex + titleCellColumnCount, rowAttrArr[0].value);
717
+ setFontSizeFamily(totalRowCount, contentColStartIndex);
718
+ setFontSizeFamily(totalRowCount, contentColStartIndex + titleCellColumnCount);
656
719
  // 合并第二个属性的标题列和值列,同时设置对应单元格的内容
657
720
  if (rowAttrArr.length > 1) {
658
721
  const colIndexTitle = contentColStartIndex + titleCellColumnCount + titleCellValColumnCount;
@@ -661,6 +724,8 @@ const BusinessUtils = {
661
724
  sheet.addSpan(totalRowCount, colIndexValue, 1, titleCellValColumnCount + 1 + (!isVertical && rowAttrArr.length == 2 ? titleCellColumnCount + titleCellValColumnCount + 1 : 0), gc.Spread.Sheets.SheetArea.viewport);
662
725
  sheet.setValue(totalRowCount, colIndexTitle, rowAttrArr[1].title);
663
726
  sheet.setValue(totalRowCount, colIndexValue, rowAttrArr[1].value);
727
+ setFontSizeFamily(totalRowCount, colIndexTitle);
728
+ setFontSizeFamily(totalRowCount, colIndexValue);
664
729
  }
665
730
  // 合并第三个属性的标题列和值列,同时设置对应单元格的内容
666
731
  if (rowAttrArr.length > 2) {
@@ -670,6 +735,8 @@ const BusinessUtils = {
670
735
  sheet.addSpan(totalRowCount, colIndexValue, 1, titleCellValColumnCount + 1, gc.Spread.Sheets.SheetArea.viewport);
671
736
  sheet.setValue(totalRowCount, colIndexTitle, rowAttrArr[2].title);
672
737
  sheet.setValue(totalRowCount, colIndexValue, rowAttrArr[2].value);
738
+ setFontSizeFamily(totalRowCount, colIndexTitle);
739
+ setFontSizeFamily(totalRowCount, colIndexValue);
673
740
  }
674
741
  }
675
742
  // 恢复绘制
@@ -18643,6 +18710,105 @@ const FormulaUtils = {
18643
18710
  return czl;
18644
18711
  },
18645
18712
  },
18713
+ {
18714
+ funName: 'YJLHL',
18715
+ funDesc: '沥青蜡含量',
18716
+ funDefaultVal: null,
18717
+ // isContainNullUndefinedVal: true,
18718
+ funParams: [
18719
+ {
18720
+ name: '析出蜡质量1',
18721
+ repeatable: false,
18722
+ optional: false,
18723
+ },
18724
+ {
18725
+ name: '析出蜡质量2',
18726
+ repeatable: false,
18727
+ optional: false,
18728
+ },
18729
+ {
18730
+ name: '析出蜡质量3',
18731
+ repeatable: false,
18732
+ optional: false,
18733
+ },
18734
+ {
18735
+ name: '蜡含量1',
18736
+ repeatable: false,
18737
+ optional: false,
18738
+ },
18739
+ {
18740
+ name: '蜡含量2',
18741
+ repeatable: false,
18742
+ optional: false,
18743
+ },
18744
+ {
18745
+ name: '蜡含量3',
18746
+ repeatable: false,
18747
+ optional: false,
18748
+ },
18749
+ ],
18750
+ funCallback: (spread, sheet, retData) => {
18751
+ //如果传递的参数小于6个,则返回空字符串
18752
+ if (retData.allCellVals.length < 6) {
18753
+ return '';
18754
+ }
18755
+ var xArr = [retData.allCellVals[0], retData.allCellVals[1], retData.allCellVals[2]]; //析出蜡质量数组
18756
+ var rArr = [retData.allCellVals[3], retData.allCellVals[4], retData.allCellVals[5]]; //蜡含量数组
18757
+ var jg;
18758
+ var MIN = 0.065;
18759
+ var MAX = 0.085;
18760
+ var ok = xArr.map((v) => +v >= MIN && +v <= MAX); //判定是否符合条件
18761
+ var idx = ok.map((v, i) => (v ? i : -1)).filter((i) => i >= 0); //符合条件个数
18762
+ if (idx.length === 0) {
18763
+ // msg = '三个值均不满足条件,请重新进行试验!';
18764
+ return '重新试验';
18765
+ }
18766
+ var vals = idx.map((i) => +rArr[i]); //符合条件的蜡质量对应的蜡含量
18767
+ var avg = vals.reduce((a, b) => a + b) / vals.length; //计算蜡含量平均值
18768
+ jg = FormulaUtils.commFun.GetDataOddIncreaseEvenDecrease(avg, -1);
18769
+ return jg;
18770
+ },
18771
+ },
18772
+ {
18773
+ funName: 'YJNFX',
18774
+ funDesc: '沥青黏附性',
18775
+ funDefaultVal: null,
18776
+ // isContainNullUndefinedVal: true,
18777
+ funParams: [
18778
+ {
18779
+ name: '沥青膜剥落情况',
18780
+ repeatable: false,
18781
+ optional: false,
18782
+ },
18783
+ ],
18784
+ funCallback: (spread, sheet, retData) => {
18785
+ //如果传递的参数小于1个,则返回空字符串
18786
+ if (retData.allCellVals.length < 1) {
18787
+ return '';
18788
+ }
18789
+ let lqmblqk = retData.allCellVals[0];
18790
+ var pddj; //最后输出的值
18791
+ if (lqmblqk == '沥青膜裹覆率接近100%') {
18792
+ pddj = '5';
18793
+ }
18794
+ else if (lqmblqk == '沥青膜少部剥落,厚度不均,沥青膜裹覆率不小于90%') {
18795
+ pddj = '4';
18796
+ }
18797
+ else if (lqmblqk == '沥青膜局部明显剥落,沥青膜裹覆率为75%~90%') {
18798
+ pddj = '3';
18799
+ }
18800
+ else if (lqmblqk == '沥青膜大部分剥落,沥青膜裹覆率为25%~75%') {
18801
+ pddj = '2';
18802
+ }
18803
+ else if (lqmblqk == '沥青膜几乎完全剥落,沥青膜裹覆率小于25%') {
18804
+ pddj = '1';
18805
+ }
18806
+ else {
18807
+ pddj = '/';
18808
+ }
18809
+ return pddj;
18810
+ },
18811
+ },
18646
18812
  ],
18647
18813
  };
18648
18814
 
@@ -18727,8 +18893,8 @@ const WorkbookUtils = {
18727
18893
  // 设置打印区域,这里是固定的,在业务应用中需要根据实际情况修改打印区域
18728
18894
  printInfo.rowStart(0);
18729
18895
  printInfo.rowEnd(sheet.getRowCount()); //printInfo.rowEnd(41);
18730
- printInfo.columnStart(0);
18731
- printInfo.columnEnd(76);
18896
+ printInfo.columnStart(1);
18897
+ printInfo.columnEnd(77);
18732
18898
  // 设置SpreadJS自身的边距为合适的距离
18733
18899
  printInfo.margin({
18734
18900
  /**
@@ -18839,12 +19005,13 @@ const WorkbookUtils = {
18839
19005
  * @param exportName 导出的文件名称,不传则为第一个Sheet的名称
18840
19006
  * @param regFonts 注册的字体集合,默认注册宋体和Arial字体
18841
19007
  * @param contentColEndIndex 内容列结束的索引,默认为:77(用于导出PDF文件的时候,只导出内容列到索引contentColEndIndex的位置,超过contentColEndIndex索引列后续的内容其实不需要导出)
19008
+ * @param isHb 是否是横表,默认为false(横表的时候,设置导出PDF的缩放比例为1,否则为1.06)
18842
19009
  * @returns 合并后的工作簿实例
18843
19010
  */
18844
19011
  mergeWorkbooksToExcelOrPdf: (GC_1, spreads_1, ...args_1) => __awaiter(void 0, [GC_1, spreads_1, ...args_1], void 0, function* (GC, spreads, isExcel = true, exportName, regFonts = [
18845
19012
  { name: '宋体', type: 'normal', url: '/spreadJsFonts/simsun.ttf' },
18846
19013
  { name: 'Arial', type: 'normal', url: '/spreadJsFonts/arial.ttf' },
18847
- ], contentColEndIndex = 77) {
19014
+ ], contentColEndIndex = 77, isHb = false) {
18848
19015
  if (!spreads || spreads.length == 0) {
18849
19016
  return;
18850
19017
  }
@@ -18933,7 +19100,7 @@ const WorkbookUtils = {
18933
19100
  printInfo.blackAndWhite(false);
18934
19101
  printInfo.showRowHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
18935
19102
  printInfo.showColumnHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
18936
- printInfo.zoomFactor(1.06); //1.06
19103
+ printInfo.zoomFactor(isHb ? 1 : 1.06);
18937
19104
  }
18938
19105
  // 恢复绘制
18939
19106
  mainWorkbook.resumePaint();