تجميع وفك تجميع الصفوف والأعمدة في Python
إدارة تجميع وفك تجميع الصفوف والأعمدة في Aspose.Cells لـ Python via Java
كيفية تجميع الصفوف والأعمدة في Python
يمكن تجميع الصفوف أو الأعمدة عن طريق استدعاء أساليب groupRows و groupColumns في مجموعة Cells. تأخذ كلا الطريقتين المعلمات التالية:
- مؤشر الصف أو العمود الأول في المجموعة.
- مؤشر الصف أو العمود الأخير في المجموعة.
- يتم إخفاءها، معلمة منطقية تحدد ما إذا كان سيتم إخفاء الصفوف/الأعمدة بعد التجميع أم لا.
كود Python
def group_rows_columns(self):
\# Instantiating a Workbook object by excel file path
workbook = self.Workbook(self.dataDir + 'Book1.xls')
\# Accessing the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
cells = worksheet.getCells()
\# Grouping first six rows (from 0 to 5) and making them hidden by passing true
cells.groupRows(0,5,True)
\# Grouping first three columns (from 0 to 2) and making them hidden by passing true
cells.groupColumns(0,2,True)
\# Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(self.dataDir + "Group Rows And Columns.xls")
print "Group Rows And Columns Successfully."
كيفية فك تجميع الصفوف والأعمدة باستخدام Python
إلغاء تجميع الصفوف أو الأعمدة المجمعة عن طريق استدعاء أساليب UngroupRows و UngroupColumns لمجموعة Cells. تأخذ كلا الطريقتين نفس المعلمات:
- الصف الأول أو فهرس العمود، الصف/العمود الأول الذي سيتم إلغاء تجميعه.
- الصف/العمود الأخير الذي سيتم إلغاء تجميعه.
كود Python
def ungroup_rows_columns(self):
\# Instantiating a Workbook object by excel file path
workbook = self.Workbook(self.dataDir + 'Group Rows And Columns.xls')
\# Accessing the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
cells = worksheet.getCells()
\# Ungrouping first six rows (from 0 to 5)
cells.ungroupRows(0,5)
\# Ungrouping first three columns (from 0 to 2)
cells.ungroupColumns(0,2)
\# Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(self.dataDir + "Ungroup Rows And Columns.xls")
print "Ungroup Rows And Columns Successfully."
تحميل رمز التشغيل
تحميل تجميع وفك تجميع الصفوف والأعمدة (Aspose.Cells) من أي من مواقع البرمجة الاجتماعية المذكورة أدناه: