Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This article explains how to apply a subtotal to data and change the direction of Outline Summary Rows Below Detail.
You can apply a subtotal to data using the Worksheet.getCells().subtotal() method. It takes the following parameters.
You can also control the direction of Outline Summary Rows Below Detail, as shown in the following screenshot, using the Worksheet.Outline.SummaryRowBelow property. This setting can be opened in Microsoft Excel via Data > Outline > Settings.

The following screenshot shows the source Excel file used in the sample code below, which contains some data in columns A and B.

The following screenshot shows the output Excel file generated by the sample code. As you can see, a subtotal has been applied to range A2:B11, and the outline direction is set to summary rows below detail.

Here is the sample code that produces the output shown above.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.