セルの結合と解除

セルの結合

ワークシート内の複数のセルを 1 つのセルに結合するために、Cells コレクションの Merge メソッドを呼び出します。Merge メソッドを呼び出す際に、結合するセルの範囲を指定します。

4 つのセルが 1 つに結合されました

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Merging cells starting from the cell with 3rd row and 3rd column.
// 2 rows and 2 columns will be merged from the starting cell
sheet.Cells.Merge(2, 2, 2, 2);

セルの結合解除

セルを結合解除するには、Merge メソッドと同じパラメータを取る Cells コレクションの UnMerge メソッドを使用します。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Unmerging cells starting from the cell with 3rd row and 3rd column.
// 2 rows and 2 columns will be unmerged from the starting cell
sheet.Cells.UnMerge(2, 2, 2, 2);