분할 테이블

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