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각 열의 너비(포인트 단위); 길이는 열 수와 같습니다.
BordersVisibleboolImageRenderOptionsOneNote에서 표 테두리가 렌더링되는지 여부
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.


참고

 한국어