TableRow / TableCell — Aspose.Note FOSS for Python API Reference
الفئة: TableRow
Properties: aspose.note Properties: from aspose.note import TableRow Properties: CompositeNode
TableRow يمثل صفًا واحدًا داخل Table. أبناؤه المباشرون هم TableCell عقد.
Properties
TableRow لا يحتوي على خصائص بخلاف تلك الموروثة من CompositeNode و Node.
موروث من CompositeNode
| خاصية / طريقة | Properties |
|---|---|
FirstChild | أول طفل مباشر TableCell,، أو None |
LastChild | آخر طفل مباشر TableCell,، أو None |
AppendChildLast(node) | إلحاق بـ TableCell |
AppendChildFirst(node) | إضافة في البداية TableCell |
InsertChild(index, node) | إدراج TableCell في موضع محدد |
RemoveChild(node) | إزالة TableCell |
GetChildNodes(Type) | بحث عميق أولاً متكرر |
for cell in row | تكرار مباشر TableCell العناصر الفرعية |
موروث من Node
| Properties | Properties |
|---|---|
ParentNode | المحتوي Table |
Document | الجذر Document |
الفئة: TableCell
Properties: aspose.note Properties: from aspose.note import TableCell Properties: CompositeNode
TableCell يمثل خلية واحدة داخل TableRow. يمكنه أن يحتوي RichText, Image,، وعقد محتوى أخرى كعناصر فرعية.
Properties
TableCell ليس له خصائص بخلاف تلك الموروثة من CompositeNode و Node.
موروث من CompositeNode
| خاصية / طريقة | Properties |
|---|---|
FirstChild | العنصر الفرعي الأول للمحتوى |
LastChild | العنصر الفرعي الأخير للمحتوى |
AppendChildLast(node) | إضافة عقدة محتوى إلى هذه الخلية |
AppendChildFirst(node) | إدراج عقدة محتوى في البداية |
InsertChild(index, node) | إدراج في موضع محدد |
RemoveChild(node) | إزالة عقدة محتوى |
GetChildNodes(Type) | بحث متكرر بنهج العمق أولاً |
for child in cell | تكرار الأطفال المباشرين |
موروث من Node
| Properties | Properties |
|---|---|
ParentNode | المحتوي TableRow |
Document | الجذر Document |
أمثلة الاستخدام
تكرار جميع صفوف الجدول والخلايا
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), "|")استخراج النص من كل خلية كقائمة مسطحة
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)إنشاء جدول برمجيًا
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)عد الصفوف والخلايا
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
TableRow و TableCell ليس لديها خصائص خاصة قابلة للـ null. قوائم الأطفال التي تُرجعها GetChildNodes دائمًا ما تكون قوائم (قد تكون فارغة).
انظر أيضًا
- Properties: الأب لـ TableRow
- RichText: المحتوى الأساسي داخل TableCell
- Properties: المحتوى الصوري داخل TableCell
- CompositeNode: طرق إدارة الأطفال الموروثة