تطبيق الإجمالي الفرعي وتغيير اتجاه صفوف ملخص المخطط التفصيلي أسفل التفاصيل

مثال

لقطات تقارن بين ملفات المصدر والمخرجات

تُظهر لقطة الشاشة التالية ملف Excel المصدر المستخدم في نموذج التعليمات البرمجية أدناه والذي يحتوي على بعض البيانات في العمودين A و B.

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

تُظهر لقطة الشاشة التالية ملف Excel الناتج الذي تم إنشاؤه بواسطة نموذج التعليمات البرمجية. كما ترى ، تم تطبيق المجموع الفرعي على النطاقأ 2: ب 11 واتجاه المخطط التفصيلي هو صفوف التلخيص أدناه التفاصيل.

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

Java كود لتطبيق المجموع الفرعي وتغيير اتجاه صفوف تلخيص المخطط التفصيلي أدناه بالتفصيل

فيما يلي نموذج التعليمات البرمجية لتحقيق الإخراج كما هو موضح أعلاه.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//directories
String sourceDir = Utils.Get_SourceDirectory();
String outputDir = Utils.Get_OutputDirectory();
// Create workbook from source Excel file
Workbook workbook = new Workbook(sourceDir + "SampleSubtotal.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Get the Cells collection in the first worksheet
Cells cells = worksheet.getCells();
// Create a cellarea i.e.., A2:B11
CellArea ca = CellArea.createCellArea("A2", "B11");
// Apply subtotal, the consolidation function is Sum and it will applied to
// Second column (B) in the list
cells.subtotal(ca, 0, ConsolidationFunction.SUM, new int[] { 1 }, true, false, true);
// Set the direction of outline summary
worksheet.getOutline().setSummaryRowBelow(true);
// Save the excel file
workbook.save(outputDir + "ASubtotal_out.xlsx");