WPT File Format

A WPT file is a JSON document that captures the complete state of a WebPivotTable session — source data, sheet configuration, and pivot layout. Users can save a WPT file at any time and re-open it later to restore their work exactly as they left it.

Top-Level Structure

{
  "format": "WPT",
  "version": "4.0",
  "source": { ... },
  "sheet": { ... }
}
Property Type Description
format string Always "WPT" — identifies the file type.
version string Format version. Current version is "4.0". Version "3.0" files are also supported for backward compatibility.
source object The data source state — mode, type, raw data (for memory mode), field metadata, URL, etc.
sheet object The sheet state — pivot field assignments (rows, columns, filters, values) and display options (grid settings, chart settings, expand/collapse state).

Source Object

The source object stores everything needed to reconstruct the data:

Property Type Description
mode string "MEMORY" (in-browser data) or "OLAP" (server-side cube).
type string Data origin: "CSV", "EXCEL", "WPT", "GSS", "WSDATA", "CUBE", etc.
data array Row data (memory mode only). Omitted when saving with ignoreData.
fields array Field metadata — id, name, cellIndex, type.
url string Original file URL (if applicable). Used to reload data when data is omitted.
delimiter string CSV delimiter (default ","").

When saving in OLAP mode, fields are omitted (they come from the cube) and no raw data is stored.

Sheet Object

The sheet object stores the pivot configuration and display preferences:

Property Type Description
pivot object Field assignments: rows, columns, filters, values, and related settings (valuesInAxis, valuesIndex, nonEmpty).
options object Display options: expand/collapse state, grid settings (cell widths, themes, cell styles), and chart settings (type, legend, tooltip, stacking).

Saving and Loading

Use the built-in APIs to work with WPT files programmatically:

const wpt = document.querySelector('web-pivot-table');

// Save — returns a JSON string
const wptString = wpt.generateWptString();

// Save — returns a JavaScript object
const wptObject = wpt.generateWptJSON();

// Save without raw data (keeps URL for reload)
const lightweight = wpt.generateWptString(true);

// Load from string
wpt.setWptString(wptString);

// Load from object
wpt.setWptObject(wptObject);

See APIs for the full method reference.