insert_subtotals
Insert SUBTOTAL formula rows after each group in an Excel sheet, using specified group and value columns, with optional grand total.
Instructions
Insert SUBTOTAL formula rows after each group in a sorted sheet.
Args: file_path: Workbook path. sheet_name: Worksheet name. group_col: Column used to group rows. value_col: Column to subtotal. subtotal_func: Excel subtotal function code (9=SUM by default). include_grand_total: Whether to append a grand total row.
Returns: dict: Summary including ranges where subtotals were inserted.
Notes: - Destructive: modifies the sheet structure and inserts new rows.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| group_col | Yes | ||
| value_col | Yes | ||
| sheet_name | Yes | ||
| subtotal_func | No | ||
| include_grand_total | No |