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

Klasse: TableRow

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

TableRow repräsentiert eine einzelne Zeile innerhalb einer Table. Seine direkten Kinder sind TableCell Knoten.


Properties

TableRow hat keine Eigenschaften über die hinaus, die von CompositeNode und Node.

Vererbt von CompositeNode

Eigenschaft / MethodeProperties
FirstChildErstes direktes Kind TableCell, oder None
LastChildLetztes direktes Kind TableCell, oder None
AppendChildLast(node)Füge ein TableCell
AppendChildFirst(node)Voranstellen eines TableCell
InsertChild(index, node)Einfügen eines TableCell an einer bestimmten Position
RemoveChild(node)Entfernen eines TableCell
GetChildNodes(Type)Rekursive Tiefensuche
for cell in rowDirekt iterieren TableCell Kinder

Geerbt von Node

PropertiesProperties
ParentNodeDas enthaltende Table
DocumentDie Wurzel Document

Klasse: TableCell

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

TableCell repräsentiert eine einzelne Zelle innerhalb einer TableRow. Es kann enthalten RichText, Image, und andere Inhaltsknoten als Kinder.


Properties

TableCell hat keine Eigenschaften über die, die von CompositeNode und Node.

Vererbt von CompositeNode

Eigenschaft / MethodeProperties
FirstChildErstes direktes Inhaltskind
LastChildLetztes direktes Inhaltskind
AppendChildLast(node)Füge einen Inhaltsknoten zu dieser Zelle hinzu
AppendChildFirst(node)Füge einen Inhaltsknoten am Anfang ein
InsertChild(index, node)An einer bestimmten Position einfügen
RemoveChild(node)Entferne einen Inhaltsknoten
GetChildNodes(Type)Rekursive Tiefensuche
for child in cellDirekte Kinder iterieren

Geerbt von Node

PropertiesProperties
ParentNodeDas enthaltende TableRow
DocumentDie Wurzel Document

Verwendungsbeispiele

Alle Tabellenzeilen und -zellen iterieren

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), "|")

Text aus jeder Zelle als flache Liste extrahieren

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)

Eine Tabelle programmgesteuert erstellen

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)

Zeilen und Zellen zählen

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‑Sicherheit

TableRow und TableCell haben keine nullable eigenen Eigenschaften. Die Kindlisten, die zurückgegeben werden von GetChildNodes sind immer Listen (können leer sein).


Siehe auch

 Deutsch