TableRow / TableCell — Aspose.Note FOSS for Python API Reference

Třída: TableRow

Properties: aspose.note Properties: from aspose.note import TableRow Properties: CompositeNode

TableRow představuje jeden řádek v Table. Jeho přímé potomky jsou TableCell uzly.


Properties

TableRow nemá žádné vlastnosti nad rámec těch, které dědí z CompositeNode a Node.

Děděno z CompositeNode

Vlastnost / MetodaProperties
FirstChildPrvní přímý potomek TableCell, nebo None
LastChildPoslední přímý potomek TableCell, nebo None
AppendChildLast(node)Přidat TableCell
AppendChildFirst(node)Přidat na začátek TableCell
InsertChild(index, node)Vložit TableCell na konkrétní pozici
RemoveChild(node)Odebrat TableCell
GetChildNodes(Type)Rekurzivní prohledávání do hloubky
for cell in rowIterovat přímo TableCell potomci

Děděno z Node

PropertiesProperties
ParentNodeObsahující Table
DocumentKořen Document

Třída: TableCell

Properties: aspose.note Properties: from aspose.note import TableCell Properties: CompositeNode

TableCell představuje jedinou buňku v TableRow. Může obsahovat RichText, Image, a další uzly obsahu jako potomky.


Properties

TableCell nemá žádné vlastnosti nad rámec těch zděděných z CompositeNode a Node.

Děděno z CompositeNode

Vlastnost / MetodaProperties
FirstChildPrvní přímý obsahový potomek
LastChildPoslední přímý obsahový potomek
AppendChildLast(node)Připojit uzel obsahu k této buňce
AppendChildFirst(node)Přidat uzel obsahu na začátek
InsertChild(index, node)Vložit na konkrétní pozici
RemoveChild(node)Odebrat uzel obsahu
GetChildNodes(Type)Rekurzivní prohledávání do hloubky
for child in cellProcházet přímé potomky

Děděno z Node

PropertiesProperties
ParentNodeObsahující TableRow
DocumentKořen Document

Příklady použití

Procházet všechny řádky a buňky tabulky

from aspose.note import Document, Table, TableRow, TableCell, RichText

doc = Document("MyNotes.one")
for table in doc.GetChildNodes(Table):
    print(f"Table column widths: {[col.Width for col in table.Columns]}")
    for row in table.GetChildNodes(TableRow):
        row_texts = []
        for cell in row.GetChildNodes(TableCell):
            texts = cell.GetChildNodes(RichText)
            cell_text = " ".join(rt.Text for rt in texts if rt.Text)
            row_texts.append(cell_text)
        print("  |", " | ".join(row_texts), "|")

Extrahovat text z každé buňky jako plochý seznam

from aspose.note import Document, TableCell, RichText

doc = Document("MyNotes.one")
for cell in doc.GetChildNodes(TableCell):
    for rt in cell.GetChildNodes(RichText):
        if rt.Text.strip():
            print(rt.Text)

Vytvořit tabulku programově

from aspose.note import (
    Document, Page, Outline, OutlineElement,
    Table, TableRow, TableCell, RichText, SaveFormat
)

doc = Document()
page = doc.AppendChildLast(Page())
outline = page.AppendChildLast(Outline())
elem = outline.AppendChildLast(OutlineElement())

from aspose.note import TableColumn
table = elem.AppendChildLast(Table(
    IsBordersVisible=True,
    Columns=[TableColumn(Width=100.0), TableColumn(Width=200.0)],
))

headers = ["Name", "Value"]
row = table.AppendChildLast(TableRow())
for header_text in headers:
    cell = row.AppendChildLast(TableCell())
    rt = cell.AppendChildLast(RichText())
    rt.Append(header_text)

data_row = table.AppendChildLast(TableRow())
for value in ["Item A", "42"]:
    cell = data_row.AppendChildLast(TableCell())
    rt = cell.AppendChildLast(RichText())
    rt.Append(value)

doc.Save("table-output.pdf", SaveFormat.Pdf)

Spočítat řádky a buňky

from aspose.note import Document, Table, TableRow, TableCell

doc = Document("MyNotes.one")
for table in doc.GetChildNodes(Table):
    rows = table.GetChildNodes(TableRow)
    cells = table.GetChildNodes(TableCell)
    print(f"Rows: {len(rows)}  Cells: {len(cells)}")

None-Safety

TableRow a TableCell nemají žádné nullable vlastní vlastnosti. Dětské seznamy vrácené metodou GetChildNodes jsou vždy seznamy (mohou být prázdné).


Viz také

 Čeština