I am a representative of Aspose.Cells team and would like to help regarding your query for subtotal() function.
Please see the method details for your reference:
public void subtotal(CellArea ca, int groupBy, int function, int totalList, boolean replace, boolean pageBreaks, boolean summaryBelowData)
Creates subtotals for the range.
ca - The range or CellArea
groupBy - The field to group by, as a zero-based integer offset
function - A ConsolidationFunction value. The subtotal function.
totalList - An array of zero-based field offsets, indicating the fields to which the subtotals are added.
replace - Indicates whether replace the current subtotals
pageBreaks - Indicates whether add page break between groups
summaryBelowData - Indicates whether add summary below data.
We also recommend you to kindly see the document on how to use or apply Subtotals feature using Aspose.Cells for Java APIs: