マージとアンマージ Cells
Contents
[
Hide
]
Aspose.Cells.GridWeb には、セルを 1 つの大きなセルに結合できる便利なユーティリティ機能があります。このトピックでは、セルをプログラムで結合する方法について説明します。
合併 Cells
Cells コレクションの Merge メソッドを呼び出して、ワークシート内の複数のセルを 1 つのセルに結合します。 Merge メソッドを呼び出すときに結合するセルの範囲を指定します。
複数のセルを結合し、各セルにデータが含まれている場合、結合後に範囲内の左上のセルの内容のみが保持されます。他のセルのデータは失われません。セルの結合を解除すると、各セルのデータが復元されます。
4 つのセルが 1 つに結合されました
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
アンマージ Cells
セルの結合を解除するには、Cells コレクションの UnMerge メソッドを使用します。このメソッドは、Merge メソッドと同じパラメーターを取り、セルの結合解除を実行します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |