Сплітній стіл
Contents
[
Hide
]
Стіл, представлений в таблиці Aspose.Words Document Object Model, складається з незалежних рядків і клітин, що дозволяє легко розбити стіл.
Щоб маніпулювати столиком, щоб розбити його на два столи, потрібно лише перенести рядки з оригінального столу до нового. Для цього потрібно підібрати ряд, за допомогою якого потрібно розбити стіл.
Ми можемо створити два таблиці з оригінального столу, використовуючи ці прості кроки:
1,1 км Створіть клон столу без затискання дітей, щоб зберегти пересувні рядки і вставити їх після оригінального столу 2,2 км Почати в зазначений ряд, перемістити всі наступні рядки в цей другий стіл
Приклад коду показує, як розбити таблицю на два таблиці за певним рядом:
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-Python-via-.NET.git. | |
doc = aw.Document(MY_DIR + "Tables.docx") | |
first_table = doc.get_child(aw.NodeType.TABLE, 0, True).as_table() | |
# We will split the table at the third row (inclusive). | |
row = first_table.rows[2] | |
# Create a new container for the split table. | |
table = first_table.clone(False).as_table() | |
# Insert the container after the original. | |
first_table.parent_node.insert_after(table, first_table) | |
# Add a buffer paragraph to ensure the tables stay apart. | |
first_table.parent_node.insert_after(aw.Paragraph(doc), first_table) | |
while True: | |
current_row = first_table.last_row | |
table.prepend_child(current_row) | |
if current_row == row: | |
break | |
doc.save(ARTIFACTS_DIR + "WorkingWithTables.split_table.docx") |