TableRow / TableCell — Aspose.Note FOSS for Python API Reference
क्लास: TableRow
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import TableRow ImageRenderOptions: CompositeNode
TableRow एक … के भीतर एक एकल पंक्ति का प्रतिनिधित्व करता है Table.इसके प्रत्यक्ष बच्चे हैं TableCell नोड्स।.
ImageRenderOptions
TableRow के पास उन गुणों के अलावा कोई गुण नहीं हैं जो CompositeNode और Node.
CompositeNode से विरासत में मिला
| प्रॉपर्टी / मेथड | ImageRenderOptions |
|---|---|
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 से विरासत में मिला
| ImageRenderOptions | ImageRenderOptions |
|---|---|
ParentNode | समावेशी Table |
Document | रूट Document |
क्लास: TableCell
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import TableCell ImageRenderOptions: CompositeNode
TableCell एक … के भीतर एक एकल कोशिका का प्रतिनिधित्व करता है TableRow. यह शामिल कर सकता है RichText, Image, और अन्य सामग्री नोड्स को बच्चों के रूप में।.
ImageRenderOptions
TableCell के द्वारा विरासत में प्राप्त गुणों से आगे कोई गुण नहीं होते हैं CompositeNode और Node.
CompositeNode से विरासत में मिला
| प्रॉपर्टी / मेथड | ImageRenderOptions |
|---|---|
FirstChild | पहला प्रत्यक्ष सामग्री बच्चा |
LastChild | अंतिम प्रत्यक्ष सामग्री बच्चा |
AppendChildLast(node) | इस कोशिका में एक सामग्री नोड जोड़ें |
AppendChildFirst(node) | एक सामग्री नोड को पहले जोड़ें |
InsertChild(index, node) | विशिष्ट स्थान पर सम्मिलित करें |
RemoveChild(node) | कंटेंट नोड हटाएँ |
GetChildNodes(Type) | पुनरावर्ती गहराई-प्रथम खोज |
for child in cell | सीधे बच्चों को दोहराएँ |
Node से विरासत में मिला
| ImageRenderOptions | ImageRenderOptions |
|---|---|
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 के पास कोई nullable स्वयं गुण नहीं हैं। द्वारा लौटाए गए चाइल्ड लिस्ट्स GetChildNodes हमेशा सूचियाँ होती हैं (खाली भी हो सकती हैं)।.
संबंधित देखें
- ImageRenderOptions: TableRow का पैरेंट
- RichText: TableCell के भीतर प्राथमिक सामग्री
- ImageRenderOptions: TableCell के भीतर छवि सामग्री
- CompositeNode: विरासत में प्राप्त बाल प्रबंधन विधियाँ