테이블 분할
Contents
[
Hide
]
Aspose.Words Document Object Model로 표현되는 테이블은 독립된 행과 셀로 구성되어 있어 테이블 분할이 용이합니다.
테이블을 조작하여 두 개의 테이블로 분할하려면 원래 테이블의 일부 행을 새 테이블로 이동하면 됩니다. 이렇게 하려면 테이블을 분할하려는 행을 선택해야 합니다.
다음의 간단한 단계에 따라 원본 테이블에서 두 개의 테이블을 만들 수 있습니다
- 이동된 행을 유지하고 원본 테이블 뒤에 삽입하려면 하위 항목을 복제하지 않고 테이블의 복제본을 만듭니다
- 지정된 행에서 시작하여 모든 후속 행을 이 두 번째 테이블로 이동합니다
다음 코드 예제에서는 특정 행에서 테이블을 두 테이블로 분할하는 방법을 보여줍니다
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-.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"); |