GridDesktop中合并和取消合并单元格

合并单元格

要将单元格合并为一个大单元格,请按照以下步骤操作:

  • 访问任何所需的工作表
  • 创建要合并的单元范围
  • 将单元范围合并成大单元格

您可以使用工作表合并方法来合并单元格。然而,可以使用CellRange对象来定义单元范围。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Creating a CellRange object starting from "B4" to "C6"
CellRange range = new CellRange("B4", "C6");
// Merging a range of cells
sheet.Merge(range);

取消合并单元格

要将大单元格取消合并为多个单元格,请按照以下步骤操作:

  • 访问任何所需的工作表
  • 访问需要取消合并的合并单元格
  • 使用合并单元格的位置取消合并大单元格为多个单元格

您可以使用工作表取消合并方法来使用其位置取消合并单元格。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Accessing the merged cell that is currently in focus
GridCell cell = sheet.GetFocusedCell();
// Unmerging a cell using its location
sheet.Unmerge(cell.Location);