تجميع وإلغاء تجميع الصفوف والأعمدة

مقدمة

في ملف Excel Microsoft ، يمكنك إنشاء مخطط تفصيلي للبيانات للسماح لك بإظهار مستويات التفاصيل وإخفائها بنقرة واحدة بالماوس.

انقر علىرموز المخطط التفصيلي، 1 ، 2 ، 3 ، + و - لعرض الصفوف أو الأعمدة التي توفر ملخصات أو عناوين للأقسام في ورقة العمل فقط بسرعة ، أو يمكنك استخدام الرموز لمشاهدة التفاصيل ضمن ملخص فردي أو عنوان كما هو موضح أدناه في الشكل :

تجميع الصفوف والأعمدة

ما يجب القيام به: image_بديل_نص

إدارة المجموعة للصفوف والأعمدة

Aspose.Cells يوفر فصل دراسي ،دفتر العمل يمثل ملف Excel Microsoft. الدفتر العمل فئة تحتوي علىأوراق عمل مجموعة تسمح بالوصول إلى كل ورقة عمل في ملف Excel. يتم تمثيل ورقة العمل بواسطةورقة عمل صف دراسي. الورقة عمل فئة توفر أCellsمجموعة تمثل جميع الخلايا في ورقة العمل.

الCellsتوفر المجموعة عدة طرق لإدارة الصفوف أو الأعمدة في ورقة العمل ، وقد تمت مناقشة القليل منها أدناه بمزيد من التفصيل.

تجميع الصفوف والأعمدة

من الممكن تجميع الصفوف أو الأعمدة عن طريق استدعاءGroupRows وgroupColumns طرقCellsمجموعة. تأخذ كلتا الطريقتين المعلمات التالية:

  • أول صف / فهرس العمود ، أول صف أو عمود في المجموعة.
  • فهرس الصف / العمود الأخير ، الصف أو العمود الأخير في المجموعة.
  • مخفي ، معلمة منطقية تحدد ما إذا كان سيتم إخفاء الصفوف / الأعمدة بعد التجميع أم لا.
// 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(GroupingRowsandColumns.class) + "RowsAndColumns/";
// Instantiating a Workbook object
Workbook workbook = new Workbook(dataDir + "Book1.xlsx");
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Grouping first six rows (from 0 to 5) and making them hidden by
// passing true
cells.groupRows(0, 5, true);
// Grouping first three columns (from 0 to 2) and making them hidden by
// passing true
cells.groupColumns(0, 2, true);
// Setting SummaryRowBelow property to false
worksheet.getOutline().setSummaryRowBelow(true);
// Setting SummaryColumnRight property to false
worksheet.getOutline().setSummaryColumnRight(true);
// Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(dataDir + "GroupingRowsandColumns_out.xlsx");

إعدادات المجموعة

Microsoft يسمح Excel أيضًا بتكوين إعدادات المجموعة لعرض:

  • صفوف التلخيص أدناه التفاصيل.
  • أعمدة التلخيص على يمين التفاصيل.

إعدادات المجموعة

ما يجب القيام به: image_بديل_نص

من الممكن تكوين إعدادات المجموعة هذه باستخدام خاصية Outline لفئة ورقة العمل.

صفوف التلخيص أدناه التفاصيل

يمكن للمطورين التحكم في عرض صفوف التلخيص أدناه بالتفصيل باستخدام ملفالخطوط العريضة صف دراسي'ملخص طريقة.

// 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(SummaryRowBelow.class) + "RowsAndColumns/";
// 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();
// Grouping first six rows (from 0 to 5) and making them hidden by passing true
cells.groupRows(0, 5, true);
// Grouping first three columns (from 0 to 2) and making them hidden by passing true
cells.groupColumns(0, 2, true);
// Setting SummaryRowBelow property to false
worksheet.getOutline().setSummaryRowBelow(false);
// Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(dataDir + "SummaryRowBelow_out.xls");

أعمدة التلخيص إلى يمين التفاصيل

من الممكن التحكم في عرض أعمدة الملخص على يمين التفاصيل باستخدام ملفالخطوط العريضة صف دراسي'ملخص العمودطريقة.

// 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(SummaryRowRight.class) + "RowsAndColumns/";
// Instantiating a Workbook object
Workbook workbook = new Workbook(dataDir + "BookStyles.xls");
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Grouping first six rows (from 0 to 5) and making them hidden by passing true
cells.ungroupRows(0, 5);
// Grouping first three columns (from 0 to 2) and making them hidden by passing true
cells.ungroupColumns(0, 2);
// Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(dataDir + "SummaryRowRight_out.xls");

فك تجميع الصفوف والأعمدة

قم بفك تجميع الصفوف أو الأعمدة المجمعة عن طريق استدعاء ملفCells المجموعةUngroupRows وUngroupColumns أساليب. تأخذ كلتا الطريقتين نفس المعلمات:

  • الصف الأول أو فهرس العمود ، الصف / العمود الأول المراد فك تجميعه.
  • فهرس الصف أو العمود الأخير ، الصف / العمود الأخير المراد فك تجميعه.
// 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(UngroupingRowsandColumns.class) + "rows_cloumns/";
// Instantiating a Workbook object
Workbook workbook = new Workbook(dataDir + "BookStyles.xls");
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Grouping first six rows (from 0 to 5) and making them hidden by
// passing true
cells.ungroupRows(0, 5);
// Grouping first three columns (from 0 to 2) and making them hidden by
// passing true
cells.ungroupColumns(0, 2);
// Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(dataDir + "UngroupingRowsandColumns_out.xls");
// Print message
System.out.println("Rows and Columns ungrouped successfully.");