Satırları ve Sütunları Gizleme ve Gösterme

Satırların ve Sütunların Görünürlüğünü Kontrol Etme

Aspose.Cells bir sınıf sağlar,Çalışma kitabı , bu bir Microsoft Excel dosyasını temsil eder. buÇalışma kitabı sınıf bir içerirÇalışma Sayfası Koleksiyonu geliştiricilerin Excel dosyasındaki her çalışma sayfasına erişmesine olanak tanır. Bir çalışma sayfası şununla temsil edilir:Çalışma kağıdı sınıf. buÇalışma kağıdı sınıf bir sağlarCells çalışma sayfasındaki tüm hücreleri temsil eden koleksiyon. buCellskoleksiyon, bir çalışma sayfasındaki satırları veya sütunları yönetmek için çeşitli yöntemler sağlar. Bunlardan birkaçı aşağıda tartışılmaktadır.

Satırları ve Sütunları Gizleme

Geliştiriciler, çağırarak bir satırı veya sütunu gizleyebilirsiniz.Satırı Gizle veSütunu Gizle yöntemleriCellssırasıyla koleksiyon. Her iki yöntem de belirli satır veya sütunu gizlemek için satır ve 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();

Satırları ve Sütunları Gösterme

Geliştiriciler, herhangi bir gizli satırı veya sütunu çağırarak gösterebilir.Satırı Göster veSütunu Göster yöntemleriCellssırasıyla koleksiyon. Her iki yöntem de iki parametre alır:

  • Satır veya sütun dizini - belirli bir satır veya sütunu göstermek için kullanılan bir satır veya sütun dizini.
  • Satır yüksekliği veya sütun genişliği - gösterildikten sonra satıra veya sütuna 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();

Birden Çok Satırı ve Sütunu Gizleme

Geliştiriciler, çağrı yaparak aynı anda birden çok satırı veya sütunu gizleyebilirsiniz.Satırları Gizle veSütunları Gizle yöntemleriCellssırasıyla koleksiyon. Her iki yöntem de başlangıç satır veya sütun indeksini 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();