تقسيم الجدول

Contents
[ ]

يتكون الجدول، الممثل في نموذج كائن المستند Aspose.Words، من صفوف وخلايا مستقلة، مما يسهل تقسيم الجدول.

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

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

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

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

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java.git.
Document doc = new Document(getMyDir() + "Tables.docx");
Table firstTable = (Table) doc.getChild(NodeType.TABLE, 0, true);
// We will split the table at the third row (inclusive).
Row row = firstTable.getRows().get(2);
// Create a new container for the split table.
Table table = (Table) firstTable.deepClone(false);
// Insert the container after the original.
firstTable.getParentNode().insertAfter(table, firstTable);
// Add a buffer paragraph to ensure the tables stay apart.
firstTable.getParentNode().insertAfter(new Paragraph(doc), firstTable);
Row currentRow;
do
{
currentRow = firstTable.getLastRow();
table.prependChild(currentRow);
} while (currentRow != row);
doc.save(getArtifactsDir() + "WorkingWithTables.SplitTable.docx");