조인 테이블
Contents
[
Hide
]
표, Aspose.Words 문서 개체 모델은 독립적 인 행과 셀로 구성되어 테이블을 쉽게 조인 할 수 있습니다.
테이블을 조작하여 다른 테이블과 결합하려면 두 번째 테이블에서 첫 번째 테이블의 끝으로 행을 이동하고 두 번째 테이블의 컨테이너를 제거하면됩니다.
다음 코드 예제에서는 두 테이블의 행을 하나로 병합하는 방법을 보여 줍니다:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
// The rows from the second table will be appended to the end of the first table. | |
auto firstTable = System::ExplicitCast<Table>(doc->GetChild(NodeType::Table, 0, true)); | |
auto secondTable = System::ExplicitCast<Table>(doc->GetChild(NodeType::Table, 1, true)); | |
// Append all rows from the current table to the next tables | |
// with different cell count and widths can be joined into one table. | |
while (secondTable->get_HasChildNodes()) | |
{ | |
firstTable->get_Rows()->Add(secondTable->get_FirstRow()); | |
} | |
secondTable->Remove(); | |
doc->Save(ArtifactsDir + u"WorkingWithTables.CombineRows.docx"); |