Satır ve Sütunları Gruplandırma ve Grubu Çözme

Giriş

Bir Microsoft Excel dosyasında, veriler için bir biçim oluşturarak tek bir fare tıklamasıyla ayrıntı seviyelerini gösterip gizleyebilirsiniz.

Yalnızca özetler veya başlıkların bulunduğu satırları veya sütunları hızlı bir şekilde görüntülemek için Özet Sembolleri, 1,2,3, + ve - simgelerine tıklayabilirsiniz veya simgeleri kullanarak bir çalışma sayfasındaki bir bölümün altındaki ayrıntıları görebilirsiniz, aşağıdaki şekilde gösterildiği gibi:

Satır ve Sütun Gruplama.
todo:image_alt_text

Satır ve Sütun Grubu Yönetimi

Aspose.Cells for Python via .NET, Microsoft Excel dosyasını temsil eden Workbook sınıfını sağlar. Workbook sınıfı, Excel dosyasındaki her çalışma sayfasına erişim sağlayan bir WorksheetCollection içerir. Bir çalışma sayfası, Worksheet sınıfı ile temsil edilir. Worksheet sınıfı, çalışma sayfasındaki tüm hücreleri temsil eden bir Cells koleksiyonu sağlar.

Cells koleksiyonu, çalışma sayfasındaki satırları veya sütunları yönetmek için birkaç yöntem sağlar, bunlardan bazıları aşağıda daha detaylı olarak tartışılmıştır.

Satır ve Sütunları Gruplama

Cells koleksiyonunun group_rows ve group_columns yöntemlerini çağırarak satırları veya sütunları gruplamak mümkündür. Her iki yöntem de aşağıdaki parametreleri alır:

  • İlk satır/sütun indeksi, grup içindeki ilk satır veya sütun.
  • Son satır/sütun indeksi, grup içindeki son satır veya sütun.
  • Gizli mi, satırları/sütunları gruplandırmadan sonra gizlemek için bir Boolean parametre.
from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Creating a file stream containing the Excel file to be opened
fstream = open(dataDir + "book1.xls", "rb")
# Opening the Excel file through the file stream
workbook = Workbook(fstream)
# Accessing the first worksheet in the Excel file
worksheet = workbook.worksheets[0]
# Grouping first six rows (from 0 to 5) and making them hidden by passing true
worksheet.cells.group_rows(0, 5, True)
# Grouping first three columns (from 0 to 2) and making them hidden by passing true
worksheet.cells.group_columns(0, 2, True)
# Saving the modified Excel file
workbook.save(dataDir + "output.xls")
# Closing the file stream to free all resources
fstream.close()

Grup Ayarları

Microsoft Excel, görüntüleme için grup ayarlarını yapılandırmanıza izin verir:

  • Detayın altında özet satırlar.
  • Ayrıntının sağında özet sütunlar.

Geliştiriciler, Worksheet sınıfının outline özelliğini kullanarak bu grup ayarlarını yapılandırabilir.

Özet Satırlarını Ayrıntıların Altına Nasıl Ayarlayacaksınız

Özet satırların detayın altında gösterilip gösterilmeyeceğini kontrol etmek de true veya false olarak summary_row_below sınıfının Outline özelliğini ayarlayarak mümkündür.

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
workbook = Workbook(dataDir + "sample.xlsx")
worksheet = workbook.worksheets[0]
# Grouping first six rows and first three columns
worksheet.cells.group_rows(0, 5, True)
worksheet.cells.group_columns(0, 2, True)
# Setting SummaryRowBelow property to false
worksheet.outline.summary_row_below = False
# Saving the modified Excel file
workbook.save(dataDir + "output.xls")

Özet Sütunlarını Ayrıntıların Sağında Nasıl Ayarlayacaksınız

Geliştiriciler, ayrıntının sağında özet sütunları göstermek veya gizlemek için Outline sınıfının summary_column_right özelliğini true veya false olarak ayarlayabilirler.

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
workbook = Workbook(dataDir + "sample.xlsx")
worksheet = workbook.worksheets[0]
# Grouping first six rows and first three columns
worksheet.cells.group_rows(0, 5, True)
worksheet.cells.group_columns(0, 2, True)
worksheet.outline.summary_column_right = True
# Saving the modified Excel file
workbook.save(dataDir + "output.xls")

Satır ve Sütunları Grubu Kaldırma

Gruplanmış herhangi bir satır veya sütunu ayırmak için, Cells koleksiyonunun ungroup_rows ve ungroup_columns metodlarını çağırın. Her iki metod da iki parametre alır:

  • İlk satır veya sütun dizini, ayrılmak istenen ilk satır/sütun.
  • Son satır veya sütun dizini, ayrılmak istenen son satır/sütun.

ungroup_rows, üçüncü bir Boolean parametresi alan bir aşırı yüklemesi vardır. true olarak ayarlayarak tüm gruplanmış bilgileri kaldırabilirsiniz. Aksi takdirde, yalnızca dış grup bilgileri kaldırılır.

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Creating a file stream containing the Excel file to be opened
fstream = open(dataDir + "book1.xls", "rb")
# Instantiating a Workbook object
# Opening the Excel file through the file stream
workbook = Workbook(fstream)
# Accessing the first worksheet in the Excel file
worksheet = workbook.worksheets[0]
# Ungrouping first six rows (from 0 to 5)
worksheet.cells.ungroup_rows(0, 5)
# Ungrouping first three columns (from 0 to 2)
worksheet.cells.ungroup_columns(0, 2)
# Saving the modified Excel file
workbook.save(dataDir + "output.xls")
# Closing the file stream to free all resources
fstream.close()