Sammanfoga och ta bort sammanfogningen Cells
Contents
[
Hide
]
Aspose.Cells.GridWeb har en praktisk verktygsfunktion som låter dig slå samman celler till en stor cell. Det här avsnittet beskriver hur man sammanfogar celler programmatiskt.
Slår ihop Cells
Slå samman flera celler i ett kalkylblad till en enda cell genom att anropa Cells-samlingens Sammanfogningsmetod. Ange intervallet av celler som ska slås samman när du anropar Sammanfogningsmetoden.
Om du slår samman flera celler och varje cell innehåller data, behålls endast innehållet i den övre vänstra cellen i intervallet efter sammanfogningen. Data i de andra cellerna går inte förlorade. Om du tar bort sammanslagningen av cellerna återställer varje cell sina data.
Fyra celler slogs samman till en
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); |
Avslutar Cells
För att ta bort sammanslagningen av celler, använd Cells-samlingens UnMerge-metod som tar samma parametrar som för Merge-metoden och utför upphävandet av celler.
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); |