Çalışsayfa Satır ve Sütunlarını Gruplama
Olası Kullanım Senaryoları
Aspose.Cells, bir çalışsayfadaki satırları ve sütunları Cells.GroupRows() ve Cells.GroupColumns() yöntemleri kullanarak gruplamanıza olanak tanır.
Çalışsayfa Satır ve Sütunlarını Gruplama
Aşağıdaki örnek kod, satırları ve sütunları gruplamanın nasıl yapıldığını göstermektedir. Kod, satırları ve sütunları 3. seviyeye kadar gruplar. Lütfen bu kod ile oluşturulan çıktı excel dosyasını kontrol edin. İlk çalışsayfada satırların gruplandırıldığı ikinci çalışsayfada ise sütunların gruplandırıldığı görülebilir. Lütfen ayrıca satırların gruplandırılmasını gösteren ekran görüntüsünü de inceleyin.
Örnek Kod
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
Aspose::Cells::Startup(); | |
//Output directory path | |
U16String outPath(u"..\\Data\\Output\\"); | |
//Path of output excel file | |
U16String outputGroupRowsAndColumnsOfWorksheet = outPath + u"outputGroupRowsAndColumnsOfWorksheet.xlsx"; | |
//Create an empty workbook | |
Workbook wb; | |
//Add worksheet for grouping rows | |
Worksheet grpRows = wb.GetWorksheets().Get(0); | |
grpRows.SetName(u"GroupRows"); | |
//Add worksheet for grouping columns | |
int idx = wb.GetWorksheets().Add(); | |
Worksheet grpCols = wb.GetWorksheets().Get(idx); | |
grpCols.SetName(u"GroupColumns"); | |
//Add sample values in both worksheets | |
for (int i = 0; i < 50; i++) | |
{ | |
U16String str(u"Text"); | |
grpRows.GetCells().Get(i, 0).PutValue(str); | |
grpCols.GetCells().Get(0, i).PutValue(str); | |
} | |
//Grouping rows at first level | |
grpRows.GetCells().GroupRows(0, 10); | |
grpRows.GetCells().GroupRows(12, 22); | |
grpRows.GetCells().GroupRows(24, 34); | |
//Grouping rows at second level | |
grpRows.GetCells().GroupRows(2, 8); | |
grpRows.GetCells().GroupRows(14, 20); | |
grpRows.GetCells().GroupRows(28, 30); | |
//Grouping rows at third level | |
grpRows.GetCells().GroupRows(5, 7); | |
//Grouping columns at first level | |
grpCols.GetCells().GroupColumns(0, 10); | |
grpCols.GetCells().GroupColumns(12, 22); | |
grpCols.GetCells().GroupColumns(24, 34); | |
//Grouping columns at second level | |
grpCols.GetCells().GroupColumns(2, 8); | |
grpCols.GetCells().GroupColumns(14, 20); | |
grpCols.GetCells().GroupColumns(28, 30); | |
//Grouping columns at third level | |
grpCols.GetCells().GroupColumns(5, 7); | |
//Save the output excel file | |
wb.Save(outputGroupRowsAndColumnsOfWorksheet); | |
Aspose::Cells::Cleanup(); |