XLSX

Pivot Tables

Create pivot tables from source data with 11 aggregation functions

Basic Pivot Table

Create a pivot table from a source data range, grouping by row fields and aggregating data:

{
  "worksheets": [
    {
      "name": "Data",
      "rows": [
        { "cells": [{ "value": "Region" }, { "value": "Product" }, { "value": "Sales" }] },
        { "cells": [{ "value": "East" }, { "value": "Widget" }, { "value": 150 }] },
        { "cells": [{ "value": "East" }, { "value": "Gadget" }, { "value": 200 }] },
        { "cells": [{ "value": "West" }, { "value": "Widget" }, { "value": 300 }] },
        { "cells": [{ "value": "West" }, { "value": "Gadget" }, { "value": 100 }] },
        { "cells": [{ "value": "North" }, { "value": "Widget" }, { "value": 250 }] },
        { "cells": [{ "value": "North" }, { "value": "Gadget" }, { "value": 175 }] }
      ]
    },
    {
      "name": "Pivot",
      "rows": [],
      "pivotTables": [
        {
          "source": "A1:C7",
          "sourceSheet": "Data",
          "location": "A3",
          "rows": ["Region"],
          "data": [{ "field": "Sales", "summarize": "sum" }]
        }
      ]
    }
  ]
}

Aggregation Functions

All 11 ST_DataConsolidateFunction types from OOXML are supported:

Functionsummarize valueDescription
Sum"sum"Sum of values (default)
Average"average"Arithmetic mean
Count"count"Count of non-empty
Count Numbers"countNums"Count of numbers
Max"max"Maximum value
Min"min"Minimum value
Product"product"Product of values
StdDev (sample)"stdDev"STDEV.S
StdDevP (population)"stdDevp"STDEV.P
Var (sample)"var"VAR.S
VarP (population)"varp"VAR.P

Multiple Data Fields

Add multiple aggregations in the same pivot table:

{
  "pivotTables": [
    {
      "source": "A1:C7",
      "sourceSheet": "Data",
      "location": "A3",
      "rows": ["Region"],
      "data": [
        { "field": "Sales", "summarize": "sum", "name": "Total Sales" },
        { "field": "Sales", "summarize": "average", "name": "Avg Sales" }
      ]
    }
  ]
}

Pivot Table Options Reference

OptionTypeDescription
sourcestringSource data range, e.g. "A1:C11"
sourceSheetstringSource sheet name (default: current sheet)
locationstringOutput start cell (default: "A3")
rowsstring[]Row field names
columnsstring[]Column field names
dataDataField[]Data field configurations
namestringPivot table name (default: "PivotTable1")
stylestringPivot style name (default: "PivotStyleLight16")

PivotDataField options

OptionTypeDescription
fieldstringSource field name to aggregate
summarizestringAggregation function (default: "sum")
namestringDisplay name (default: "Sum of {field}")
Copyright © 2026