שולחן מפוצל

Contents
[ ]

טבלה, המיוצגת במודל אובייקט המסמך Aspose.Words, מורכבת משורות ותאים עצמאיים, מה שמקל על פיצול טבלה.

כדי לתפעל טבלה כדי לפצל אותה לשני שולחנות, עלינו רק להעביר חלק מהשורות מהטבלה המקורית לטבלה החדשה. כדי לעשות זאת, אנחנו צריכים לבחור את השורה שבה אנחנו רוצים לפצל את השולחן.

אנו יכולים ליצור שתי טבלאות מהטבלה המקורית על ידי ביצוע השלבים הפשוטים הבאים:

  1. צור שיבוט של הטבלה מבלי לשכפל את הילדים כדי לשמור על השורות שהועברו ולהכניס אותן לאחר הטבלה המקורית
  2. החל מהשורה שצוינה, העבר את כל השורות הבאות לטבלה שנייה זו

דוגמת הקוד הבאה מראה כיצד לחלק טבלה לשתי טבלאות בשורה ספציפית:

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