TableRow / TableCell

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

Sınıf: TableRow

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

TableRow içinde tek bir satırı temsil eder Table.Doğrudan alt öğeleri şunlardır TableCell düğümler.


Enumerations

TableRow şu kaynaklardan devralınanların ötesinde hiçbir özelliği yoktur CompositeNode ve Node.

CompositeNode’dan kalıtılmış

Özellik / YöntemEnumerations
FirstChildİlk doğrudan alt öğe TableCell, ya da None
LastChildSon doğrudan alt öğe TableCell, ya da None
AppendChildLast(node)Ekle TableCell
AppendChildFirst(node)Başına ekle TableCell
InsertChild(index, node)Araya ekle TableCell belirli bir konumda
RemoveChild(node)Kaldır TableCell
GetChildNodes(Type)Özyinelemeli derin öncelikli arama
for cell in rowDoğrudan yinele TableCell çocuklar

Node’dan miras alındı

EnumerationsEnumerations
ParentNodeİçeren Table
DocumentKök Document

Sınıf: TableCell

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

TableCell bir … içinde tek bir hücreyi temsil eder TableRow. İçerebilir RichText, Image, ve diğer içerik düğümlerini çocuk olarak.


Enumerations

TableCell şunlardan devralınanların ötesinde hiçbir özelliği yoktur CompositeNode ve Node.

CompositeNode’dan kalıtılmış

Özellik / MetotEnumerations
FirstChildİlk doğrudan içerik çocuğu
LastChildSon doğrudan içerik çocuğu
AppendChildLast(node)Bu hücreye bir içerik düğümü ekle
AppendChildFirst(node)Bir içerik düğümünü başa ekle
InsertChild(index, node)Belirli bir konuma ekle
RemoveChild(node)Bir içerik düğümünü kaldır
GetChildNodes(Type)Özyinelemeli derinlik öncelikli arama
for child in cellDoğrudan çocukları yinele

Node’dan miras alındı

EnumerationsEnumerations
ParentNodeİçeren TableRow
DocumentKök Document

Kullanım Örnekleri

Tüm tablo satırlarını ve hücrelerini yineleyin

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

Her hücreden metni düz bir liste olarak çıkarın

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)

Programlı olarak bir tablo oluşturun

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)

Satırları ve hücreleri sayın

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-Güvenliği

TableRow ve TableCell null olabilen kendi özellikleri yoktur. Tarafından döndürülen çocuk listeleri GetChildNodes her zaman listedir (boş olabilir).


Ayrıca Bakınız

 Türkçe