---
title: "pivot.collapse: Expand/Collapse Field — Sheet kit command — Kition"
description: "Collapses or expands items of a pivot table field (default: all items)."
canonical: "https://developer.kition.ai/docs/kits/sheet/commands/pivot.collapse"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/sheet/commands/pivot.collapse](https://developer.kition.ai/docs/kits/sheet/commands/pivot.collapse)

# pivot.collapse

**Expand/Collapse Field.** Collapses or expands items of a pivot table field (default: all items).

- Kit: Sheet 0.1.0 (.xlsx (and opens .xlsm, .xls, .xltx, .csv, .ods, .xlsb)); reference: [Sheet kit commands](https://developer.kition.ai/docs/kits/sheet.md)
- Changes the document: yes

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `collapse` | `boolean` | no |  |
| `field` | `string` | no | a source field name or a value field caption |
| `items` | `any[]` | no | [labels] (default: all); default: all |
| `pivot` | `string \| integer` | no | default: the pivot table at the active cell |
| `replace` | `boolean` | no | replace the existing pivot table output in place |

## Call through sheet_run

```text
sheet_run {
  "path": "<file>.xlsx",
  "steps": [{ "command": "pivot.collapse" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `collapse`, `field`, `items`, `pivot`, `replace`. sheet_run answers the step’s result in `completed[i].result`.

## Result

The kit gives no result schema for this command.

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "collapse": {
      "default": true,
      "type": "boolean"
    },
    "field": {
      "description": "a source field name or a value field caption",
      "type": "string"
    },
    "items": {
      "description": "[labels] (default: all); default: all",
      "items": {},
      "type": "array"
    },
    "pivot": {
      "description": "default: the pivot table at the active cell",
      "oneOf": [
        {
          "description": "a pivot table name",
          "type": "string"
        },
        {
          "description": "a pivot table id",
          "type": "integer"
        }
      ]
    },
    "replace": {
      "description": "replace the existing pivot table output in place",
      "type": "boolean"
    }
  },
  "type": "object"
}
```

Generated from the command list of @kition/sheet-darwin-arm64@0.1.0 and the kit itself (sheet_commands through @kition/cli@0.1.1, built from KitionAI/kition-sheet@82f13b2).
