تعيين حدود النطاق
Contents
[
Hide
]
سيناريوهات الاستخدام المحتملة
عندما ترغب في تعيين الحدود للنطاق ، لا داعي لتعيين كل خلية على حده. يمكنك تعيين الحدود على النطاق. تقدم Aspose.Cells for Python via .NET هذه الميزة. يوفر هذا المقال رمزًا عينيًا يستخدم Aspose.Cells for Python via .NET لتعيين حدود النطاق.
كيفية تعيين حدود النطاق في Excel
لتعيين الحدود لنطاق في Excel، يمكنك اتباع هذه الخطوات:
- حدد نطاق الخلايا التي ترغب في تطبيق الحد لها.
- في علامة التبويب “الرئيسية” في الشريط، ابحث عن مجموعة “الخط”.
- ضمن مجموعة “الخط”، انقر فوق زر القائمة المنسدلة “الحدود”.
- اختر نوع الحد الذي ترغب في تطبيقه من الخيارات المتاحة في القائمة المنسدلة. يمكنك اختيار أنماط الحدود المعدة مسبقًا أو تخصيص حدودك الخاصة.
- بمجرد اختيارك لنمط الحد المطلوب، سيتم تطبيق الحد على النطاق المحدد من الخلايا.
كيفية تعيين حدود النطاق باستخدام Aspose.Cells for مكتبة Python Excel
يوضح هذا المثال كيف:
- إنشاء دفتر عمل.
- إضافة بيانات إلى الخلايا في ورقة العمل الأولى.
- إنشاء Range.
- تعيين الحدود الداخلية للنطاق.
- تعيين الحدود الخارجية للنطاق.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import BorderType, CellBorderType, Workbook | |
from aspose.pydrawing import Color | |
# Instantiating an Workbook object | |
workbook = Workbook() | |
# Obtaining the reference of the newly added worksheet | |
ws = workbook.worksheets[0] | |
cells = ws.cells | |
# Setting the value to the cells | |
cell = cells.get("A1") | |
cell.put_value("Fruit") | |
cell = cells.get("B1") | |
cell.put_value("Count") | |
cell = cells.get("C1") | |
cell.put_value("Price") | |
cell = cells.get("A2") | |
cell.put_value("Apple") | |
cell = cells.get("A3") | |
cell.put_value("Mango") | |
cell = cells.get("A4") | |
cell.put_value("Blackberry") | |
cell = cells.get("A5") | |
cell.put_value("Cherry") | |
cell = cells.get("B2") | |
cell.put_value(5) | |
cell = cells.get("B3") | |
cell.put_value(3) | |
cell = cells.get("B4") | |
cell.put_value(6) | |
cell = cells.get("B5") | |
cell.put_value(4) | |
cell = cells.get("C2") | |
cell.put_value(5) | |
cell = cells.get("C3") | |
cell.put_value(20) | |
cell = cells.get("C4") | |
cell.put_value(30) | |
cell = cells.get("C5") | |
cell.put_value(60) | |
# Create a range (A1:C5). | |
range = cells.create_range("A1", "C5") | |
# set inner borer of range | |
innerColor = workbook.create_cells_color() | |
innerColor.color = Color.red | |
range.set_inside_borders(BorderType.VERTICAL, CellBorderType.THIN, innerColor) | |
innerColor.color = Color.green | |
range.set_inside_borders(BorderType.HORIZONTAL, CellBorderType.THIN, innerColor) | |
# set outer borer of range | |
outerColor = workbook.create_cells_color() | |
outerColor.color = Color.blue | |
range.set_outline_borders(CellBorderType.THIN, outerColor) | |
workbook.save("out.xlsx") |