Çalışma Sayfasında Birleştirilmiş Cells'i Algıla

Gösteri

Bu örnek, adlı bir şablon Microsoft Excel dosyası kullanır.Birleştirme Denemesi. Birleştirme Denemesi olarak da adlandırılan bir sayfada bazı birleştirilmiş hücre alanları vardır.

şablon dosyası

yapılacaklar:resim_alternatif_metin

Aspose.Cells şunları sağlar:Cells.getMergedCellsbirleştirilmiş hücre alanlarının ArrayList’ini almak için kullanılan yöntem.

Aşağıdaki kod yürütüldüğünde, sayfanın içeriğini temizler ve dosyayı yeniden kaydetmeden önce tüm hücre alanlarını ayırır.

Çıktı Dosyası

yapılacaklar:resim_alternatif_metin

Kod Örneği

Bir çalışma sayfasındaki birleştirilmiş hücre alanlarını nasıl belirleyeceğinizi ve bunları nasıl ayıracağınızı öğrenmek için lütfen aşağıdaki örnek koda bakın.

// 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.getDataDir(DetectMergedCells.class);
// Instantiate a new Workbook
Workbook wkBook = new Workbook(dataDir + "MergeTrial.xls");
// Get a worksheet in the workbook
Worksheet wkSheet = wkBook.getWorksheets().get("Merge Trial");
// Clear its contents
wkSheet.getCells().clearContents(0, 0, wkSheet.getCells().getMaxDataRow(),
wkSheet.getCells().getMaxDataColumn());
// Get all merged cell aeras
CellArea[] areas = wkSheet.getCells().getMergedAreas();
// Define some variables
int frow, fcol, erow, ecol;
// Loop through the arraylist and get each cellarea to unmerge it
for (int i = areas.length - 1; i > -1; i--)
{
frow = areas[i].StartRow;
fcol = areas[i].StartColumn;
erow = areas[i].EndRow;
ecol = areas[i].EndColumn;
wkSheet.getCells().unMerge(frow, fcol, erow, ecol);
}
// Save the excel file
wkBook.save(dataDir + "output_MergeTrial.xls");

İlgili Makaleler