Options

WebPivotTable uses options internally to control its look and feel and behaviour. Changing any option triggers WebPivotTable to refresh and the change takes effect immediately.

Setting these options is the primary mechanism to customise WebPivotTable.

How To Set Options?

There are two ways to set options:

  • Passing options as an attribute of the web-pivot-table tag

  <web-pivot-table
    options='{"localeFilePath": "./locales/", "locale":"en", "leavePageWarning": 0}'>
  </web-pivot-table>

Since an attribute of an HTML tag or custom element can only be a string, we need to stringify options when passing them this way. WebPivotTable will convert this string to a JavaScript object and deeply merge it into the default options.

It is easy to make mistakes when writing options as a JSON string, so this approach works best for a small number of simple values. When using WebPivotTable together with a JavaScript framework such as React or Vue, you can pass a JavaScript object directly as a prop, making complex options easy to manage.

See the [Quick Start](/quick-start) page for framework integration examples.
  • Calling the setOptions method

    After the <web-pivot-table> element is created on the page, you can call setOptions directly on the element:

      const wpt = document.querySelector('web-pivot-table');
    
      wpt.setOptions({
        localeFilePath: "./locales/",
        locale: "en",
        leavePageWarning: 0,
      });
    

    Because you pass a plain JavaScript object that is deeply merged into the default options, this is the preferred way to set complex or nested options.

    See [APIs](/doc/apis) for the full list of available methods.

`leavePageWarning`

Option Type Default Description
leavePageWarning number 0 Show a warning dialog when the user navigates away from the page that contains WebPivotTable. Set to 1 to enable.

If enabled, the browser shows a confirmation dialog giving end users a chance to save their work before leaving. The dialog is a native browser dialog and may look different across browsers.

`locale`

Option Type Default Description
locale string 'en' Current language locale. Should be one of the values in availableLocales.

`localeFilePath`

Option Type Default Description
localeFilePath string './locales/' Path to the directory containing locale JSON files. Used for backward compatibility; see also localeDeploymentMode.

`localeDeploymentMode`

Option Type Default Description
localeDeploymentMode string 'cdn' How locale files are resolved. 'cdn' loads from the CDN; 'self-host' loads from localeFilePath.

`localeBaseUrl`

Option Type Default Description
localeBaseUrl string '' Explicit locale base URL. When set, this takes the highest priority over both localeDeploymentMode and localeFilePath.

`localeCdnBaseUrl`

Option Type Default Description
localeCdnBaseUrl string '' Optional custom CDN base URL for locale files. Only used when localeDeploymentMode is 'cdn' and localeBaseUrl is empty.

`availableLocales`

Option Type Default Description
availableLocales array see below Selectable locales shown in the language switcher.

Default availableLocales:

[
  { value: 'en',    abbr: 'EN', label: 'Lbl_English',    attach: ' ( english ) ' },
  { value: 'zh-CN', abbr: 'CN', label: 'Lbl_Chinese',    attach: ' ( 中文 ) ' },
  { value: 'de',    abbr: 'DE', label: 'Lbl_German',     attach: ' ( deutsch ) ' },
  { value: 'tr-TR', abbr: 'TR', label: 'Lbl_Turkish',    attach: ' ( türk ) ' },
  { value: 'es',    abbr: 'ES', label: 'Lbl_Spanish',    attach: ' ( español ) ' },
  { value: 'pt',    abbr: 'PT', label: 'Lbl_Portuguese', attach: ' ( português ) ' },
  { value: 'it',    abbr: 'IT', label: 'Lbl_Italian',    attach: ' ( italiano ) ' },
]
Property Type Description
value string Locale code
abbr string Abbreviation shown on the header
label string Message key in the language file used as the label
attach string Appended to the label using the native language translation

Additional locales (French, Arabic, Russian, Dutch, Greek, Hebrew, Hindi, Hungarian, Swedish, Korean, Japanese, Vietnamese) are defined but commented out by default. Uncomment them in your options to enable.

Please reference Internationalization for more details.

`server`

Option Type Default Description
server.fileProxyEnabled number 1 Enable/disable the file proxy for cross-origin requests
server.fileProxy string 'https://new.webpivottable.com/api/wpt/file-proxy' URL of the file proxy endpoint
server.fileTimeout number 30000 File request timeout in milliseconds
server.xmlaProxyEnabled number 1 Enable/disable the XMLA proxy for OLAP connections
server.xmlaProxy string 'https://new.webpivottable.com/api/wpt/xmla-proxy' URL of the XMLA proxy endpoint
server.xmlaTimeout number 30000 XMLA request timeout in milliseconds
server.basicAuthEnabled number 0 Enable/disable basic authentication
server.username string 'username' Default username for authenticated requests
server.password string 'password' Default password for authenticated requests
server.rolesEnabled number 0 Enable/disable role-based access control
server.roles string 'test' Comma-separated roles list

See Cross-Domain Access for details on how the proxy works and how to deploy your own proxy server.

`limit`

Option Type Default Description
limit.sourceDataMaxRows number 100000 Maximum rows allowed in memory mode
limit.sourceDataMaxColumns number 1000 Maximum columns allowed in memory mode
limit.sourceDataMaxDataCells number 10000000 Maximum total data cells (rows × columns)
limit.sheetLayoutMaxRows number 1000 Maximum rows to display in the pivot grid
limit.sheetLayoutMaxColumns number 1000 Maximum columns to display in the pivot grid
limit.sheetLayoutMaxDataCells number 10000 Maximum data cells for pivot layout
limit.olapDrillThroughMaxRows number 1000 Maximum rows returned per OLAP drill-through query

Responsive Breakpoints

Option Type Default Description
smallScreenBreakpoint number 768 Width threshold for small screens (phones)
mediumScreenBreakpoint number 1080 Width threshold for medium screens (tablets)

Number Formatting

Option Type Default Description
decimalPoint string '.' Decimal separator character
thousandsSep string ',' Thousands separator character
defaultToDistinctCount number 0 Use DISTINCTCOUNT instead of SUM as the default statistic for string fields

`defaultValueFormat`

Option Type Default Description
defaultValueFormat.category string Constants.valueFormatCategory.NUMBER Default format category for value fields
defaultValueFormat.negative string Constants.negativeValueFormat.RED_MINUS Default format for negative numbers

Interaction Options

Option Type Default Description
drillThroughBySingleClick number 0 Trigger drill-through on single click instead of double-click
deferLayoutExcludeFilter number 0 Exclude field sort/filter changes from deferred layout updates
deferLayoutUpdate boolean false Defer pivot layout recalculation for improved performance. When enabled, pivot data is not regenerated until the user explicitly triggers an update.

`uiFlags`

UI flags control the visibility of various interface elements. Set any flag to 0 to hide the corresponding feature.

Option Type Default Description
uiFlags.dropPrompt number 1 Show drag-and-drop prompt text
uiFlags.pivotPrompt number 1 Show pivot instruction prompts
uiFlags.connectSource number 1 Show the connect data source button
uiFlags.open number 1 Show the open file button
uiFlags.save number 1 Show the save file button
uiFlags.reset number 1 Show the reset pivot button
uiFlags.fullScreen number 1 Show the full-screen toggle
uiFlags.language number 1 Show the language selector
uiFlags.source number 1 Show the source data explorer
uiFlags.export number 1 Show the export button
uiFlags.loadFromCsv number 1 Allow loading CSV files
uiFlags.loadFromExcel number 1 Allow loading Excel files
uiFlags.loadFromGss number 1 Allow loading Google Sheets
uiFlags.loadFromWs number 1 Allow loading from a Web Service
uiFlags.loadFromOlap number 1 Allow connecting to OLAP cubes
uiFlags.saveToLocal number 1 Allow saving to a local file
uiFlags.saveToServer number 1 Allow saving to a server

`controlPanel`

The control panel houses the Rows, Columns, Filters, and Values field areas used to build the pivot table.

Option Type Default Description
controlPanel.show number 1 Show (1) or hide (0) the control panel
controlPanel.floating number 0 Floating panel (1) or docked (0)
controlPanel.position string 'right' Panel position: 'left' or 'right'
controlPanel.stacked number 0 Stack field areas vertically (1) or side by side (0)
controlPanel.width number 350 Panel width in pixels
controlPanel.height number 200 Panel height in pixels

`styles`

Option Type Default Description
styles.highLightColor string 'rgb(250, 224, 177)' Highlight colour for selected cells
styles.messageColor string 'orangered' Colour for error/status messages
styles.lineHeight number 30 Default line height in pixels
styles.wpt.fontSize string '14px' Base font size for the pivot table
styles.wpt.border string '1px solid #888' Outer border of the pivot table
styles.wpt.background string '#fff' Background colour of the pivot table
styles.modal.padding string '0' Padding inside modal dialogs
styles.header.borderBottom string '1px solid #888' Header bottom border
styles.header.backgroundColor string 'lightblue' Header background colour
styles.toolbar.backgroundColor string 'aliceblue' Toolbar background colour
Option Type Default Description
fileLinks array see below Sample file links shown in the connect-data dialog.

Each entry is an object with type, url, and label:

{ type: Constants.sourceType.CSV, url: 'https://cdn.webpivottable.com/samples/example.csv', label: 'USA Selection Poll Data' }

Default links include a variety of CSV, Excel (.xls / .xlsx), WPT, Google Sheets, Web Service, and OLAP sample files hosted at cdn.webpivottable.com/samples/.

You can override this array to supply your own sample files:

wpt.setOptions({
  fileLinks: [
    { type: 'csv',   url: '/data/sales.csv',       label: 'Sales Data' },
    { type: 'excel', url: '/data/inventory.xlsx',   label: 'Inventory Data' },
  ],
});

`customHandlers`

Option Type Default Description
customHandlers.connectSource number 0 Enable custom handler for "Connect Data Source" action
customHandlers.openWpt number 0 Enable custom handler for "Open WPT" action
customHandlers.saveWpt number 0 Enable custom handler for "Save WPT" action
customHandlers.drillThrough number 0 Enable custom handler for drill-through action

Setting a custom handler to 1 tells WebPivotTable to fire a DOM event instead of performing the default behaviour. You then listen for the event and implement your own logic:

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

// Enable custom save handler
wpt.setOptions({
  customHandlers: { saveWpt: 1 },
});

// Listen for the save event
wpt.addEventListener('SAVE_WPT', (e) => {
  const wptData = e.detail;
  // Save wptData to your backend
  fetch('/api/save', {
    method: 'POST',
    body: JSON.stringify(wptData),
  });
});

See Events for the full list of events.

`filestack`

Option Type Default Description
filestack.enabled boolean true Enable the Filestack file picker integration
filestack.key string 'A4bieoUsyR4yBrNPkFIvrz' Filestack API key

`layout`

Option Type Default Description
layout.headerReserve number 180 Space reserved for headers in pixels
layout.aspectRatio number 1.6 Preferred aspect ratio for grid/chart
layout.fitMode string 'fill' How content fits the container: 'fill', 'contain', or 'cover'

`fullscreen`

Option Type Default Description
fullscreen boolean false Whether the application is in full-screen mode

Sheet Options

Each sheet created within WebPivotTable uses the following default display options. These are not set via setOptions but are the defaults applied when a new sheet is created.

Display

Option Type Default Description
displayMode string 'chart' Initial display mode for new sheets
expandRows number 1 Expand all rows by default
expandCols number 1 Expand all columns by default
showRowTotals number 1 Show row totals
showColTotals number 1 Show column totals
showRowSubtotals number 1 Show row subtotals
showColSubtotals number 1 Show column subtotals

Grid

Option Type Default Description
grid.showSigns number 1 Show +/- signs for expand/collapse
grid.showEmptyAsZero number 0 Display empty cells as zero
grid.compactForm number 1 Use compact form for row headers
grid.rowHeaderWidth number 200 Row header width in pixels
grid.cellWidth number 100 Data cell width in pixels
grid.cellHeight number 20 Data cell height in pixels
grid.theme string 'wpt-default' Grid colour theme
grid.noFixedColumns number 0 Disable fixed (frozen) columns

Grid cell styles can be customised per cell type via grid.cellStyle:

grid: {
  cellStyle: {
    columnHeader:   { textAlign: 'center', backgroundColor: '#bfd6eb', fontWeight: 'bold' },
    compoundColumn: { verticalAlign: 'top', textAlign: 'left', backgroundColor: '#bfd6eb', fontWeight: 'bold' },
    rowHeader:      { textAlign: 'left', backgroundColor: '#bfd6eb', fontWeight: 'bold' },
    compoundRow:    { verticalAlign: 'top', textAlign: 'left', backgroundColor: '#bfd6eb', fontWeight: 'bold' },
    totalCell:      { textAlign: 'right', backgroundColor: '#72d2df' },
    subtotalCell:   { textAlign: 'right', backgroundColor: '#d2e9e9' },
    dataCell:       { textAlign: 'right', backgroundColor: '#eee' },
    noDataCell:     { backgroundColor: '#ddd' },
  },
}

Chart

Option Type Default Description
chart.combined boolean true Combine chart with grid
chart.high.theme string 'default' Highcharts theme
chart.high.chart.type string 'column' Chart type: column, bar, line, spline, area, areaspline, pie
chart.high.chart.options3d.enabled boolean false Enable 3D rendering
chart.high.legend.enabled boolean true Show chart legend
chart.high.legend.layout string 'vertical' Legend layout: 'horizontal' or 'vertical'
chart.high.legend.align string 'right' Legend alignment: 'left', 'center', 'right'
chart.high.tooltip.enabled boolean true Show tooltips on hover
chart.high.plotOptions.series.stacking string|null null Stacking mode: null, 'normal', 'percent'

See the Highcharts documentation for the full list of chart options supported under chart.high.