조인 테이블

Contents
[ ]

Aspose.Words문서 개체 모델에 표시되는 테이블은 독립적인 행과 셀로 구성되어 있어 테이블을 쉽게 조인할 수 있습니다.

테이블을 조작하여 다른 테이블과 결합하려면 두 번째 테이블에서 첫 번째 테이블의 끝으로 행을 이동하고 두 번째 테이블의 컨테이너를 제거하면됩니다.

다음 코드 예제에서는 두 테이블의 행을 하나로 병합하는 방법을 보여 줍니다:

// 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");
// The rows from the second table will be appended to the end of the first table.
Table firstTable = (Table) doc.getChild(NodeType.TABLE, 0, true);
Table secondTable = (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.hasChildNodes())
firstTable.getRows().add(secondTable.getFirstRow());
secondTable.remove();
doc.save(getArtifactsDir() + "WorkingWithTables.CombineRows.docx");