APIs

WebPivotTable provides lots of APIs for developers to call them from hosted web page or web application. For example, developers can use these APIs to load source data from any kind of resources, or save reports to local files or server then reload them in future, etc.

How to call APIs?

WebPivotTable follow web component standard. We can put WebPivotTable on any web page just like it is a HTML tag. When web page loaded, there is a corresponding element created on DOM. Then we can call document.getElementsByTagName to get an javascript object of the element. Each API of WebPivotTable is a method of this javascript object.

Below is standard syntax to call APIs:

var wpt = document.getElementsByTagName('web-pivot-table')[0];

wpt.apiName(params1, params2, ..., paramsn);

Most of WebPivotTable APIs are asynchronous, it will return a Promise.

setLocale

wpt.setLocale(locale);
Param Name Param Type Optional Description
locale String no locale code

setOptions

wpt.setOptions(options);
Param Name Param Type Optional Description
options Object no customize options

This setOptions API is a major way to customize WebPivotTable, see Options for more details.

getOptions

var options = wpt.getOptions();

showControlPanel

wpt.showControlPanel();

hideControlPanel

wpt.hideControlPanel();

toggleControlPanel

wpt.toggleControlPanel();

openDialog

wpt.openDialog({ type: "" , width: "", height: ""});
Param Name Param Type Optional Description
type String no
width String yes
height String yes
payload Object yes

closeDialog

wpt.closeDialog();

reset

wpt.reset();

refresh

wpt.refresh();

loadingMessage

wpt.loadingMessage(message);
Param Name Param Type Optional Description
message String no

clearMessage

wpt.clearMessage();

errorMessage

wpt.errorMessage(error);
Param Name Param Type Optional Description
error String or Object no

setWptFromDataArray

wpt.setWptFromDataArray(attrArray, dataArray, dataUrl, url, type);
Param Name Param Type Optional Description
attrArray Array no Array of attributes. example: ["department", "area", "cost", ...]
dataArray Array no Array of data rows, each row is also an array of values. example: [["dep1", "area1", 1000, ...], ..., ["dep6", "area2", 2000,...]]
url String yes Url for track the source data, This is just for tracking, pass "" if not know or no need.
type Object yes pre-saved wpt JSON object

Load source data from data array

Notes:

  • This is major API to load source data into WebPivotTable, it was used by setWptFromCsvUrl and setWptFromExcelUrl internally. Actually, developers can load any kinds of data from any other resources, like SQL databases, and format them as attrArray and dataArray, then load them into WebPivotTable.

getSourceFromDataArray

wpt.getSourceFromDataArray(attrArray, dataArray, dataUrl, url, type);
Param Name Param Type Optional Description
attrArray Array no Array of attributes. example: ["department", "area", "cost", ...]
dataArray Array no Array of data rows, each row is also an array of values. example: [["dep1", "area1", 1000, ...], ..., ["dep6", "area2", 2000,...]]
url String yes Url for track the source data, This is just for tracking, pass "" if not know or no need.
type Object yes pre-saved wpt JSON object

setWptFromCsvUrl

wpt.setWptFromCsvUrl(url, delimiter);
Param Name Param Type Optional Description
url String no URL String of CSV file
delimiter String yes separator char for CSV file, default is ","

Set wpt from CSV file URL

getSourceFromCsvUrl

wpt.getSourceFromCsvUrl(url, delimiter);
Param Name Param Type Optional Description
url String no URL String of CSV file
delimiter String yes separator char for CSV file, default is ","

Load source data from CSV file URL

setWptFromExcelUrl

wpt.setWptFromExcelUrl(url, delimiter);
Param Name Param Type Optional Description
url String no URL String of Excel file
delimiter String yes separator char for Excel file, default is ","

Set wpt from Excel file URL

getSourceFromExcelUrl

wpt.getSourceFromExcelUrl(url, delimiter);
Param Name Param Type Optional Description
url String no URL String of Excel file
delimiter String yes separator char for Excel file, default is ","

Load source data from Excel file URL

setWptFromWebService

wpt.setWptFromWebService(url);
Param Name Param Type Optional Description
url String no URL String of Web Service

Set wpt from Web Service

getSourceFromWebService

wpt.getSourceFromWebService(url);
Param Name Param Type Optional Description
url String no URL String of Web Service

Load source data from Web Service URL

setWptFromGoogleSpreadSheet

wpt.setWptFromGoogleSpreadSheet(url);
Param Name Param Type Optional Description
url String no URL String of Google Spread Sheet

Set wpt from Google Spread Sheet

getSourceFromGoogleSpreadSheet

wpt.getSourceFromGoogleSpreadSheet(url);
Param Name Param Type Optional Description
url String no URL String of Google Spread Sheet

Load source data from Google Spread Sheet URL

setWptFromWptUrl

wpt.setWptFromWptUrl(url);
Param Name Param Type Optional Description
url String no URL String of wpt file

Set wpt from wpt file

setWptFromLocalFile

wpt.setWptFromLocalFile(file, type);
Param Name Param Type Optional Description
file Object no local file
type String no file type

Set wpt from local file

setWpt

wpt.setWpt(wpt);
Param Name Param Type Optional Description
wpt String or Object no wpt string or object

Set wpt from wpt string or object

setWptFromOlapCube

wpt.setWptFromOlapCube(olapData);
Param Name Param Type Optional Description
olapData Object no Object of OLAP Cube Information

Load OLAP Cube

olapData: {
  xmlaUrl: "Xmla server url",
  dataSourceInfo: "Data source info",
  catalog: "Catalog name",
  cubeName: "Cube name"
}

getSourceFromOlapCube

wpt.getSourceFromOlapCube(olapData);
Param Name Param Type Optional Description
olapData Object no Object of OLAP Cube Information
olapData: {
  xmlaUrl: "Xmla server url",
  dataSourceInfo: "Data source info",
  catalog: "Catalog name",
  cubeName: "Cube name"
}

Load source data from Olap Cube

generateWptString

wpt.generateWptString(ignoreData);
Param Name Param Type Optional Description
ignoreData Boolean no if equal to true, ignore data and fields, only save options and controls

Generate WPT format string

generateWptJSON

wpt.generateWptJSON(ignoreData);
Param Name Param Type Optional Description
ignoreData Boolean no if equal to true, ignore data and fields, only save options and controls

Generate WPT format JSON object

getSourceObject

wpt.getSourceObject();

Get source object

setSourceObject

wpt.setSourceObject(source);
Param Name Param Type Optional Description
source Object no

Set source object