在 GridDesktop 中合并和取消合并 Cells
Contents
[
Hide
]
在本主题中,我们将讨论合并和取消合并工作表单元格的实用功能。当我们需要跨越某些行或列以增强数据的可读性时,此功能非常有用。
合并 Cells
要将单元格合并为一个大单元格,请按照以下步骤操作:
- 访问任何想要的工作表
- 创建一个范围Cells合并
- 合并单元格的范围变成一个大单元格
您可以使用合并的方法工作表合并单元格。但是,可以使用定义一系列单元格单元格范围目的。
This file contains hidden or 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 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); |
取消合并 Cells
要将一个大单元格拆分为多个单元格,请按照以下步骤操作:
- 访问任何想要的工作表
- 访问需要取消合并的合并单元格
- 取消合并使用合并单元格的位置将大单元格分成许多单元格
您可以使用取消合并的方法工作表使用其位置取消合并单元格。
This file contains hidden or 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 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); |
当您将单元格合并为单个单元格时,左上角单元格(在单元格范围内)的格式设置将应用于合并的单元格,但当单元格未合并时,所有未合并的单元格将保持其格式设置。