Satırları ve Sütunları Gizleme ve Gösterme
Giriş
Bazen, kullanıcılar tarafından çalışma sayfasının belirli satırlarını veya sütunlarını gizlemek ve daha sonra bunları görüntülemek de gerekebilir. Microsoft Excel bu özelliği sağlar ve Aspose.Cells gibi.
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ı KoleksiyonuExcel dosyasındaki her çalışma sayfasına erişim sağlar. 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 bazıları aşağıda tartışılmaktadır.
Satırları veya 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/sütun dizinini parametre olarak alır.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(HidingRowsandColumns.class) + "rows_cloumns/"; | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
// Hiding the 3rd row of the worksheet | |
cells.hideRow(2); | |
// Hiding the 2nd column of the worksheet | |
cells.hideColumn(1); | |
// Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(dataDir + "HidingRowsandColumns_out.xls"); | |
// Print message | |
System.out.println("Rows and Columns hidden successfully."); |
Satırları ve Sütunları Gösterme
Geliştiriciler, çağırarak herhangi bir gizli satırı veya sütunu 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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(UnhidingRowsandColumns.class) + "rows_cloumns/"; | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
// Unhiding the 3rd row and setting its height to 13.5 | |
cells.unhideRow(2, 13.5); | |
// Unhiding the 2nd column and setting its width to 8.5 | |
cells.unhideColumn(1, 8.5); | |
// Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(dataDir + "UnhidingRowsandColumns_out.xls"); | |
// Print message | |
System.out.println("Rows and Columns unhidden successfully."); |