Skip to content
Office Open

XLSX

Freeze Panes & Auto Filter

Freeze rows/columns and add auto-filter dropdowns

#Freeze Panes

Freeze rows and/or columns to keep headers visible while scrolling:

JSON
{
  "worksheets": [
    {
      "name": "Sheet1",
      "freezePanes": { "row": 1 },
      "rows": [
        { "cells": [{ "value": "Header 1" }, { "value": "Header 2" }] },
        { "cells": [{ "value": "Data 1" }, { "value": "Data 2" }] },
        { "cells": [{ "value": "Data 3" }, { "value": "Data 4" }] }
      ]
    }
  ]
}

Freeze both rows and columns:

JSON
{
  "worksheets": [
    {
      "name": "Sheet1",
      "freezePanes": { "row": 2, "col": 1 },
      "rows": [
        { "cells": [{ "value": "Title" }, { "value": "A" }, { "value": "B" }] },
        { "cells": [{ "value": "Name" }, { "value": "Score" }, { "value": "Grade" }] },
        { "cells": [{ "value": "Alice" }, { "value": 95 }, { "value": "A" }] }
      ]
    }
  ]
}

#Auto Filter

Add auto-filter dropdowns to a range of columns:

JSON
{
  "worksheets": [
    {
      "name": "Sheet1",
      "autoFilter": "A1:D4",
      "rows": [
        {
          "cells": [
            { "value": "Name" },
            { "value": "Age" },
            { "value": "City" },
            { "value": "Score" }
          ]
        },
        { "cells": [{ "value": "Alice" }, { "value": 30 }, { "value": "NY" }, { "value": 95 }] },
        { "cells": [{ "value": "Bob" }, { "value": 25 }, { "value": "LA" }, { "value": 88 }] },
        { "cells": [{ "value": "Carol" }, { "value": 28 }, { "value": "SF" }, { "value": 72 }] }
      ]
    }
  ]
}

The autoFilter string specifies the cell range that will have filter dropdowns. Excel will show filter arrows on the header row.

#Structured Filter

Use the object form to record which values each column filters on (what Excel writes back after the user applies a filter):

JSON
{
  "worksheets": [
    {
      "name": "Sheet1",
      "autoFilter": {
        "ref": "A1:D4",
        "columns": [
          {
            "colId": 0,
            "filters": { "values": ["Alice", "Carol"] }
          },
          {
            "colId": 3,
            "top10": { "top": true, "val": 1 }
          }
        ]
      },
      "rows": [
        {
          "cells": [
            { "value": "Name" },
            { "value": "Age" },
            { "value": "City" },
            { "value": "Score" }
          ]
        },
        { "cells": [{ "value": "Alice" }, { "value": 30 }, { "value": "NY" }, { "value": 95 }] },
        { "cells": [{ "value": "Bob" }, { "value": 25 }, { "value": "LA" }, { "value": 88 }] },
        { "cells": [{ "value": "Carol" }, { "value": 28 }, { "value": "SF" }, { "value": 72 }] }
      ]
    }
  ]
}

colId is the zero-based column index within the filter range. Each column carries exactly one filter kind:

OptionTypeDescription
refstringFilter range, e.g. "A1:D4"
columnsFilterColumnOptions[]One entry per filtered column
sortStateSortStateOptionsSort state recorded with the filter

#FilterColumn Options

OptionTypeDescription
colIdnumberZero-based column index within the filter range (required)
hiddenButtonbooleanHide the filter dropdown button
showButtonbooleanShow the filter button (default true)
filtersobjectValue/date filters: { values?: string[], dateGroupItems?: […], blank?, calendarType? }
customFiltersobjectComparison filters: { and?: boolean, entries: [{ operator?, val }] } with operators equal/notEqual/greaterThan/greaterThanOrEqual/lessThan/lessThanOrEqual
top10objectTop-N filter: { top?: boolean, percent?: boolean, val: number, filterVal?: number }
dynamicFilterobjectDynamic filter: { type: "today" | "thisMonth" | "Q1" | …, val?, maxVal?, valIso?, maxValIso? }
colorFilterobjectColor filter: { dxfId?: number, cellColor?: boolean }
iconFilterobjectIcon filter: { iconSet: IconSetType, iconId?: number }

#FreezePane Options Reference

OptionTypeDescription
rownumberNumber of rows to freeze
colnumberNumber of columns to freeze