Sammanfoga och avsammanfoga celler

Sammanfoga celler

Sammanfoga flera celler i en arbetsblad till en enda cell genom att anropa Cells-samlingen Merge-metod. Ange det cellintervall som ska sammanfogas vid anrop av Merge-metoden.

Fyra celler sammanfogade till en

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);

Avsakmanfoga celler

För att avsakmanfoga celler, använd Cells-samlingens UnMerge-metod som tar samma parametrar som Merge-metoden och utför avsakmanfogningen av celler.

// 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);