您好,经过调研我们发现,出现该报错的原因是,您前一次设置autoMerge的区域和后一次设置autoMerge的区域存在交集。clear方法无法清除前一次设置autoMerge的区域,我们需要将AutoMergeDirection设置为none,如下所示:
【需要注意的是,我们清除autoMerge区域时传入的range和设置自动autoMerge的区域必须完全一致】
- let range1 = new GC.Spread.Sheets.Range(0, 0, 10, 2);
- activeSheet.autoMerge(
- range1,
- GC.Spread.Sheets.AutoMerge.AutoMergeDirection.none,
- GC.Spread.Sheets.AutoMerge.AutoMergeMode.free,
- GC.Spread.Sheets.SheetArea.viewport,
- GC.Spread.Sheets.AutoMerge.SelectionMode.merged
- );
- activeSheet.autoMerge(
- range1,
- GC.Spread.Sheets.AutoMerge.AutoMergeDirection.column,
- GC.Spread.Sheets.AutoMerge.AutoMergeMode.free,
- GC.Spread.Sheets.SheetArea.viewport,
- GC.Spread.Sheets.AutoMerge.SelectionMode.merged
- );
- activeSheet.autoMerge(range1, GC.Spread.Sheets.AutoMerge.AutoMergeDirection.none);// 清除autoMerge区域,这里传入的range参数必须和之前的autoMerge的range一模一样
- let range2 = new GC.Spread.Sheets.Range(0, 0, 11, 2);
- activeSheet.autoMerge(
- range2,
- GC.Spread.Sheets.AutoMerge.AutoMergeDirection.none,
- GC.Spread.Sheets.AutoMerge.AutoMergeMode.free,
- GC.Spread.Sheets.SheetArea.viewport,
- GC.Spread.Sheets.AutoMerge.SelectionMode.merged
- );
- activeSheet.autoMerge(
- range2,
- GC.Spread.Sheets.AutoMerge.AutoMergeDirection.column,
- GC.Spread.Sheets.AutoMerge.AutoMergeMode.free,
- GC.Spread.Sheets.SheetArea.viewport,
- GC.Spread.Sheets.AutoMerge.SelectionMode.merged
- );
复制代码
|