Table

aspose-cells-foss Excel संरचित तालिकाओं (ListObjects) को के माध्यम से दर्शाता है Table क्लास और TableCollection के रूप में उपलब्ध ws.list_objects. तालिकाएँ नामित रेंज, ऑटो‑फ़िल्टर, हेडर पंक्तियाँ, और बैंडेड‑रो स्टाइलिंग प्रदान करती हैं जो XLSX फ़ॉर्मेट में निर्मित है।.

ImageRenderOptions: aspose.cells_foss

from aspose.cells_foss import TableStyleInfo, TableColumn

TableStyleInfo

एक तालिका पर लागू दृश्य शैली का वर्णन करता है (बैंडिंग, प्रथम/अंतिम कॉलम हाइलाइट)।.

ImageRenderOptions

TableStyleInfo()

ImageRenderOptions

NameTypeAccessDescription
name``ReadGets the name.
display_name``ReadGets the display name.
ref``ReadGets the ref.
has_headers``ReadGets the has headers.
show_totals_row``ReadGets the show totals row.
show_auto_filter``ReadGets the show auto filter.
table_style_info``ReadGets the table style info.
columnslistReadGets the columns.

TableColumn

एक तालिका के भीतर एकल कॉलम का वर्णन करता है।.

ImageRenderOptions

TableColumn(col_id: int, name: str)
SignatureDescription
__init__(name: str, ref: str, has_headers: bool)
copy()

ImageRenderOptions


ImageRenderOptions

Table ऑब्जेक्ट्स सीधे निर्मित नहीं होते हैं। उपयोग करें ws.list_objects.add(...) या ws.list_objects.add_with_range(...).

ImageRenderOptions


TableCollection

TableCollection को इस रूप में एक्सेस किया जाता है ws.list_objects. यह वर्कशीट पर सभी संरचित तालिकाओं का प्रबंधन करता है।.

ImageRenderOptions

जोड़ें

ws.list_objects.add(
    start_row: int,
    start_col: int,
    end_row: int,
    end_col: int,
    has_headers: bool = True,
    name: str | None = None
) -> Table

दिए गए सेल रेंज पर एक तालिका बनाता है। सभी इंडेक्स हैं 0-based. यदि name है None, एक नाम स्वचालित रूप से उत्पन्न किया जाता है (उदाहरण के लिए,., "Table1").

add_with_range

ws.list_objects.add_with_range(
    cell_range: str,
    name: str | None = None,
    has_headers: bool = True
) -> Table

A1‑शैली की रेंज स्ट्रिंग से तालिका बनाता है (उदाहरण के लिए,., "A1:D10"). से अधिक पठनीय add() हार्डकोडेड रेंजों के लिए।.

गुणधर्म और पुनरावृत्ति


ImageRenderOptions

निम्नलिखित उदाहरण एक उत्पाद इन्वेंटरी डेटासेट लिखता है और उसे कुल पंक्ति के साथ एक स्टाइल्ड Excel तालिका में परिवर्तित करता है।.

from aspose.cells_foss import Workbook

wb = Workbook()
ws = wb.worksheets[0]
ws.name = "Inventory"

# Write header and data rows
headers = ["SKU", "Product", "Qty", "Unit Price"]
rows = [
    ["A001", "Widget Alpha", 150, 12.99],
    ["A002", "Widget Beta",   80, 24.50],
    ["A003", "Gadget Gamma",  45, 49.99],
    ["A004", "Gadget Delta",  210, 8.75],
]

for col, h in enumerate(headers):
    ws.cells[0][col].put_value(h)
for row_i, row in enumerate(rows, start=1):
    for col_i, val in enumerate(row):
        ws.cells[row_i][col_i].put_value(val)

# Create a table over A1:D5
table = ws.list_objects.add_with_range("A1:D5", name="InventoryTable")

# Configure style
table.table_style_info.name = "TableStyleMedium9"
table.table_style_info.show_row_stripes = True
table.table_style_info.show_first_column = False
table.table_style_info.show_last_column = False

# Add a totals row with sum on Qty and Unit Price columns
table.show_totals_row = True
table.columns[2].totals_row_function = "sum"    # Qty
table.columns[3].totals_row_function = "sum"    # Unit Price
table.columns[0].totals_row_label = "Total"

wb.save("inventory_table.xlsx")

संबंधित देखें

 हिन्दी