rapid-spreadjs 1.0.152 → 1.0.153

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
@@ -552,8 +552,9 @@ const SheetUtils = {
552
552
  col: 0
553
553
  }]
554
554
  * @param isAutoSize 是否自适应单元格大小(默认为:true)
555
+ * @param isRange 是否为范围选择(默认为:false,如果设置为true,则显示的格式为2026-05-06至2026-05-08【如果选择的范围内只有1天,则显示的格式为2026-05-06】)
555
556
  */
556
- setSheetCellDate: (GC, sheet, cells, isAutoSize = true) => {
557
+ setSheetCellDate: (GC, sheet, cells, isAutoSize = true, isRange = false) => {
557
558
  cells.forEach((item, index) => {
558
559
  // 先获取单元格样式,否则设置控件后样式会丢失
559
560
  let cellStyle = sheet.getStyle(item.row, item.col);
@@ -574,11 +575,13 @@ const SheetUtils = {
574
575
  type: GC.Spread.Sheets.DropDownType.dateTimePicker,
575
576
  option: {
576
577
  showTime: false,
577
- showDateRange: false,
578
+ showDateRange: isRange,
578
579
  },
579
580
  },
580
581
  ];
581
- cellStyle.formatter = item.dateFormat;
582
+ cellStyle.formatter = !isRange
583
+ ? item.dateFormat
584
+ : '=IF(ISBLANK(@), "", IF(TEXT(@.start, "yyyy-mm-dd")=TEXT(@.end, "yyyy-mm-dd"), TEXT(@.start, "yyyy-mm-dd"), TEXT(@.start, "yyyy-mm-dd")&"至"&TEXT(@.end, "yyyy-mm-dd")))';
582
585
  // 是否缩小以适应
583
586
  cellStyle.shrinkToFit = isAutoSize;
584
587
  // 设置单元格样式