The above code will select the A7:I34 range and subtotal the values in the 8th column while breaking on values in the first column, and provide grouping and labeling of the subtotal subgroups on each subtotal line.
I performed this function in Excel by going to the Data menu, Subtotals option. Can this type of subtotaling be done in Aspose?
Try creating an Excel spreadsheet as follows:
NAME SALES
Bob 90
Bob 95
Lawrence 101
Lawrence 403
Then select the ten cells containing data (five rows and two columns), go to Data, Subtotals. Change on NAME, use the Sum function, add subtotals to SALES, and take a look at what Excel does. You will see subtotal rows inserted, along with labels and subtotal values, and a grand total at the bottom, along with grouping functionality on the left side of the worksheet.
Well, Implementing subtotals and grandtotals automatically against your data is not supported yet, you have to manually do using Cell.Formula. We may consider this feature in future. Currently, you can implement subtotals while implementing pivot tables which Aspose.Cells APIs support now.
Please note, Aspose.Excel has been changed to become Aspose.Cells now. The new API is more robust and feature rich and includes many advanced level features. Aspose.Cells supports Subtotal feature. See the article with example code for your reference: How to create Subtotals in Excel spreadsheet
Also, See the sample code on how to create Subtotals in the worksheet for your reference:
e.g. Sample code:
// Instantiate a new workbook
// Open the template file
Workbook workbook = new Workbook("book1.xlsx");
// Get the Cells collection in the first worksheet
Cells cells = workbook.Worksheets[0].Cells;
// Create a cellarea i.e.., B3:C19
CellArea ca = new CellArea();
ca.StartRow = 2;
ca.StartColumn = 1;
ca.EndRow = 18;
ca.EndColumn = 2;
// Apply subtotal, the consolidation function is Sum and it will applied to
// Second column (C) in the list
cells.Subtotal(ca, 0, ConsolidationFunction.Sum, new int[] { 1 });
// Save the excel file
workbook.Save("output.out.xlsx");
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.