Creating Subtotals
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 for Node.js via C++ API
Aspose.Cells for Node.js via C++ provides a class, Workbook, that represents a Microsoft Excel file. The Workbook class contains a Worksheets collection that allows access to each worksheet in the Excel file.
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 using the Aspose.Cells for Node.js via C++ 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 Node.js via C++.