جدول الانقسام

Contents
[ ]

يتكون الجدول، الممثل في Aspose.Words Document Object Model، من صفوف وخلايا مستقلة، مما يجعل من السهل تقسيم الجدول.

للتعامل مع جدول لتقسيمه إلى جدولين، نحتاج فقط إلى نقل بعض الصفوف من الجدول الأصلي إلى الجدول الجديد. للقيام بذلك، نحتاج إلى اختيار الصف الذي نريد تقسيم الجدول به.

يمكننا إنشاء جدولين من الجدول الأصلي باتباع الخطوات البسيطة التالية:

  1. قم بإنشاء نسخة من الجدول دون استنساخ الأطفال للاحتفاظ بالصفوف المنقولة وإدراجها بعد الجدول الأصلي
  2. بدءًا من الصف المحدد، انقل جميع الصفوف اللاحقة إلى هذا الجدول الثاني

يوضح مثال التعليمات البرمجية التالي كيفية تقسيم جدول إلى جدولين في صف معين:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git.
Document doc = new Document(MyDir + "Tables.docx");
Table firstTable = (Table) doc.GetChild(NodeType.Table, 0, true);
// We will split the table at the third row (inclusive).
Row row = firstTable.Rows[2];
// Create a new container for the split table.
Table table = (Table) firstTable.Clone(false);
// Insert the container after the original.
firstTable.ParentNode.InsertAfter(table, firstTable);
// Add a buffer paragraph to ensure the tables stay apart.
firstTable.ParentNode.InsertAfter(new Paragraph(doc), firstTable);
Row currentRow;
do
{
currentRow = firstTable.LastRow;
table.PrependChild(currentRow);
} while (currentRow != row);
doc.Save(ArtifactsDir + "WorkingWithTables.SplitTable.docx");
view raw split-table.cs hosted with ❤ by GitHub