Satırları Sütunları ve Kaydırma Çubuklarını Göster ve Gizle

Satır ve Sütunları Göster ve Gizle

Aspose.Cells, bir Microsoft Excel dosyasını temsil eden bir Workbook sınıfı sağlar. Workbook sınıfı, Excel dosyasındaki her çalışma sayfasına erişim sağlayan bir Worksheets koleksiyonu içerir. Bir çalışma sayfası, Worksheet sınıfı tarafından temsil edilmektedir. Worksheet sınıfı, çalışma sayfasındaki tüm hücreleri temsil eden bir Cells koleksiyonu sağlar. Cells koleksiyonu, çalışma sayfasında satırları veya sütunları yönetmek için birkaç yöntem sağlar. Bunlardan bazıları aşağıda tartışılmıştır.

Satır ve Sütunları Göster

Geliştiriciler, Cells koleksiyonunun sırasıyla UnhideRow ve UnhideColumn metodlarını çağırarak gizlenen herhangi bir satır veya sütunu gösterebilirler. Her iki metod da iki parametre alır:

  • Satır veya sütun dizini - belirli bir satır veya sütunun gösterilmesi için kullanılan dizin.
  • Satır yüksekliği veya sütun genişliği - gizlendikten sonra atanan satır yüksekliği veya sütun genişliği.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);
// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
// Unhiding the 3rd row and setting its height to 13.5
worksheet.Cells.UnhideRow(2, 13.5);
// Unhiding the 2nd column and setting its width to 8.5
worksheet.Cells.UnhideColumn(1, 8.5);
// Saving the modified Excel file
workbook.Save(dataDir + "output.xls");
// Closing the file stream to free all resources
fstream.Close();

Satır ve Sütunları Gizle

Geliştiriciler, Cells koleksiyonunun sırasıyla HideRow ve HideColumn metodlarını çağırarak bir satır veya sütunu gizleyebilirler. Her iki metod da belirli satır veya sütunu gizlemek için satır veya sütun dizinini parametre olarak alır.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);
// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
// Hiding the 3rd row of the worksheet
worksheet.Cells.HideRow(2);
// Hiding the 2nd column of the worksheet
worksheet.Cells.HideColumn(1);
// Saving the modified Excel file
workbook.Save(dataDir + "output.out.xls");
// Closing the file stream to free all resources
fstream.Close();

Birden Fazla Satır ve Sütunu Gizleme

Geliştiriciler, Cells koleksiyonunun sırasıyla HideRows ve HideColumns metodlarını çağırarak bir defada birden fazla satır veya sütunu gizleyebilirler. Her iki metod da gizlenmesi gereken başlangıç satırı veya sütunu dizini ve gizlenmesi gereken satır veya sütun sayısını parametre olarak alır.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);
// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
// Hiding 3,4 and 5 rows in the worksheet
worksheet.Cells.HideRows(2, 3);
// Hiding 2 and 3 columns in the worksheet
worksheet.Cells.HideColumns(1, 2);
// Saving the modified Excel file
workbook.Save(dataDir + "outputxls");
// Closing the file stream to free all resources
fstream.Close();

Kaydırma Çubuklarını Göster ve Gizle

Kaydırma çubukları, herhangi bir dosyanın içeriğini gezinmek için kullanılır. Genellikle iki tür kaydırma çubuğu bulunur:

  • Dikey kaydırma çubukları
  • Yatay kaydırma çubukları

Microsoft Excel ayrıca yatay ve dikey kaydırma çubukları sağlar böylece kullanıcılar çalışma sayfası içeriğinde kaydırma yapabilirler. Aspose.Cells kullanarak geliştiriciler Excel dosyalarında her iki türde de kaydırma çubuklarının görünürlüğünü kontrol edebilirler.

Kaydırma Çubuklarının Görünürlüğünü Kontrol Etmek

Aspose.Cells, bir Excel dosyasını temsil eden Workbook sınıfını sağlar. Workbook sınıfı bir Excel dosyasını yönetmek için geniş bir yelpazede özellik ve metot sağlar. Kaydırma çubuklarının görünürlüğünü kontrol etmek için Workbook sınıfının WorkbookSettings.IsVScrollBarVisible ve WorkbookSettings.IsHScrollBarVisible özelliklerini kullanın. WorkbookSettings.IsVScrollBarVisible ve WorkbookSettings.IsHScrollBarVisible Boolean özellikleridir, bu da bu özelliklerin yalnızca true veya false değerlerini saklayabileceği anlamına gelir.

Kaydırma Çubuklarını Görünür Yapma

Kaydırma çubuklarını görünür yapmak için Workbook sınıfının WorkbookSettings.IsVScrollBarVisible veya WorkbookSettings.IsHScrollBarVisible özelliğini true olarak ayarlayın.

Kaydırma çubuklarını gizleme

Kaydırma çubuklarını gizlemek için Workbook sınıfının WorkbookSettings.IsVScrollBarVisible veya WorkbookSettings.IsHScrollBarVisible özelliğini false olarak ayarlayın.

Örnek Kod

Aşağıda, bir Excel dosyasını, book1.xls’yi açan, her iki kaydırma çubuğunu gizleyen ve ardından değiştirilmiş dosyayı output.xls olarak kaydeden tam bir kod bulunmaktadır.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);
// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);
// Hiding the vertical scroll bar of the Excel file
workbook.Settings.IsVScrollBarVisible = false;
// Hiding the horizontal scroll bar of the Excel file
workbook.Settings.IsHScrollBarVisible = false;
// Saving the modified Excel file
workbook.Save(dataDir + "output.xls");
// Closing the file stream to free all resources
fstream.Close();