officefileapi-devexpress-dot-docs-dot-presentation-dot-table-dot-mergecells-x28-devexpress-dot-docs-dot-presentation-dot-tablecell-devexpress-dot-docs-dot-presentation-dot-tablecell-x29.md
Merges two adjacent table cells into one cell.
Namespace : DevExpress.Docs.Presentation
Assembly : DevExpress.Docs.Presentation.v25.2.dll
NuGet Package : DevExpress.Docs.Presentation
public void MergeCells(
TableCell tableCell1,
TableCell tableCell2
)
Public Sub MergeCells(
tableCell1 As TableCell,
tableCell2 As TableCell
)
| Name | Type | Description |
|---|---|---|
| tableCell1 | TableCell |
The first table cell to merge.
| | tableCell2 | TableCell |
The second table cell to merge.
|
Call the Table.MergeCells method to merge a rectangular range of table cells. The first cell in the method parameters specifies the start of the range, and the second specifies the end of the range. After the cells are merged, the Presentation API performs the following steps:
Paragraphs collection.TextArea property of merged cells is set to null.true depending on the position of merged cells.The following code snippet merges two cells in a table:
using DevExpress.Docs.Presentation;
namespace PresentationApiSample;
public class Program {
public static void Main(string[] _) {
//...
// Create a 3x3 table (rows x columns) and add it as a shape to the slide
Table table = new Table(3, 3);
slide.Shapes.Add(table);
for (int row = 0; row < 3; row++) {
for (int column = 0; column < 3; column++) {
table[row, column].TextArea.Text = $"({row}, {column})";
}
}
table.MergeCells(table[0, 0], table[0, 1]);
}
}
Imports DevExpress.Docs.Presentation
Namespace PresentationApiSample
Public Class Program
Public Shared Sub Main(__ As String())
'...
' Create a 3x3 table (rows x columns) and add it as a shape to the slide
Dim table As Table = New Table(3, 3)
slide.Shapes.Add(table)
For row As Integer = 0 To 2
For column As Integer = 0 To 2
table(row, column).TextArea.Text = $"({row}, {column})"
Next
Next
table.MergeCells(table(0, 0), table(0, 1))
End Sub
End Class
End Namespace
See Also