Table, TableRow, TableCell — Aspose.Note FOSS for Python API Reference

Κλάση: Table

ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import Table ImageRenderOptions: CompositeNode

Table αντιπροσωπεύει έναν πίνακα μέσα σε ένα OutlineElement.κρατά μια λίστα των TableRow παιδιών και εκθέτει τα πλάτη των στηλών και την ορατότητα των περιγραμμάτων.

ImageRenderOptions

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
ColumnWidthslist[float]ImageRenderOptionsΠλάτος κάθε στήλης σε σημεία· το μήκος ισούται με τον αριθμό των στηλών
BordersVisibleboolImageRenderOptionsΑν τα περιγράμματα του πίνακα αποδίδονται στο OneNote
Tagslist[NoteTag]ImageRenderOptionsΕτικέτες OneNote που συνδέονται με αυτόν τον πίνακα

Κληρονομείται από CompositeNode / Node

FirstChild, LastChild, GetChildNodes(Type), for row in table, ParentNode, Document


Κλάση: TableRow

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

TableRow είναι μια μοναδική γραμμή μέσα σε ένα Table.Τα άμεσα παιδιά του είναι TableCell κόμβοι.

ImageRenderOptions

rows = table.GetChildNodes(TableRow)
for row in rows:
    cells = row.GetChildNodes(TableCell)

Κλάση: TableCell

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

TableCell είναι ένα μοναδικό κελί μέσα σε ένα TableRow.Μπορεί να περιέχει RichText, Image, και άλλους κόμβους περιεχομένου.

ImageRenderOptions

for cell in row.GetChildNodes(TableCell):
    text = " ".join(rt.Text for rt in cell.GetChildNodes(RichText))

Παραδείγματα Χρήσης

Ανάγνωση όλων των πινάκων: πλήρης διάσχιση

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

doc = Document("MyNotes.one")
for t_num, table in enumerate(doc.GetChildNodes(Table), start=1):
    print(f"\nTable {t_num}  cols={len(table.ColumnWidths)}  widths={table.ColumnWidths}")
    for r_num, row in enumerate(table.GetChildNodes(TableRow), start=1):
        cells = row.GetChildNodes(TableCell)
        row_data = [
            " ".join(rt.Text for rt in cell.GetChildNodes(RichText)).strip()
            for cell in cells
        ]
        print(f"  Row {r_num}: {row_data}")

Εξαγωγή πινάκων σε CSV

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

doc = Document("MyNotes.one")
buf = io.StringIO()
writer = csv.writer(buf)

for table in doc.GetChildNodes(Table):
    for row in table.GetChildNodes(TableRow):
        values = [
            " ".join(rt.Text for rt in cell.GetChildNodes(RichText)).strip()
            for cell in row.GetChildNodes(TableCell)
        ]
        writer.writerow(values)
    writer.writerow([])

csv_text = buf.getvalue()
print(csv_text)

Καταμέτρηση γραμμών και στηλών

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

doc = Document("MyNotes.one")
for i, table in enumerate(doc.GetChildNodes(Table), start=1):
    rows = table.GetChildNodes(TableRow)
    cols = len(rows[0].GetChildNodes(TableCell)) if rows else 0
    print(f"Table {i}: {len(rows)} row(s) x {cols} column(s)")

Πίνακες με εικόνες στα κελιά

Τα κελιά μπορούν να περιέχουν Image κόμβους παράλληλα ή αντί για RichText:

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

doc = Document("MyNotes.one")
for table in doc.GetChildNodes(Table):
    for row in table.GetChildNodes(TableRow):
        for cell in row.GetChildNodes(TableCell):
            texts = cell.GetChildNodes(RichText)
            images = cell.GetChildNodes(Image)
            if images:
                print(f"  Cell with {len(images)} image(s) and {len(texts)} text(s)")

Επιθεώρηση ετικετών σε έναν πίνακα

from aspose.note import Document, Table

doc = Document("MyNotes.one")
for table in doc.GetChildNodes(Table):
    for tag in table.Tags:
        print(f"Table tag: {tag.label!r}  completed={tag.completed}")

Θέση DOM

OutlineElement
  └── Table
        └── TableRow (0..n)
              └── TableCell (0..n)
                    ├── RichText (0..n)
                    └── Image (0..n)

Table είναι πάντα παιδί του OutlineElement.Χρησιμοποιήστε table.ParentNode για πρόσβαση στο περιεχόμενο OutlineElement.


Δείτε επίσης

 Ελληνικά