Using Microsoft Excel
To add subtotals in Microsoft Excel:
- Create a simple data list in the first worksheet of the workbook (as shown in the figure below) and save the file as Book1.xls.
- Select any cell within your list.
- From the Data menu, select Subtotals. The Subtotals dialog will be displayed. Define what function to use and where to place the subtotals.
Using the Aspose.Cells API
A worksheet is represented by the Worksheet class. The class provides a wide range of properties and methods for managing worksheets and other objects. Each worksheet consists of a Cells collection. To add subtotals to a worksheet, use the Cells class' Subtotal method. Provide parameter values to the method to specify how the subtotal should be calculated and placed.
In the examples below, we have added subtotals to the first worksheet of the template file (Book1.xls) using the Aspose.Cells API. When the code is executed, a worksheet with subtotals is created.
The code snippets that follow show how to add subtotals to a worksheet with Aspose.Cells for .NET.