The content of dhtmlxPivot can be easily exported to the Excel or CSV format.
To export Pivot to an Excel file make use of the xlsx() method of the Export module. As a parameter, you should pass an object with export settings:
pivot.export.xlsx({
name:"pivot_data",
url:"//export.dhtmlx.com/excel"
});
The xlsx() method returns an object with data and export parameters:
var data = {
name:"pivot_data",
columns:[
{ width: 100 },
{ width: 100 }
// more objects
],
header:[
[" ", " ", "Q1", " ", "Q2", " "],
[" ", " ", "Oil (Max)", "Oil (Min)", "Oil (Max)", "Oil (Min)"]
],
data:[
["Constitutional monarchy", " ", "78.276", "2.946", "80.259", "5.564"],
[" ", 2012, "23.650", "23.650", "80.259", "51.127"],
// more arrays with cells values
],
styles:[
css:{
major:{ color: "#ff00ff", background: "#0000AA", fontSize: 14 }
},
cells:[
[1,2,"major"]
]
]
}
Below you will find the details on each of the data parameters:
var data = {
name:"pivot_data"
}
var data = {
columns:[
{ width: 100 },
{ width: 100 }
// more objects
]
}
var data = {
header:[
[" ", " ", "Q1", " ", "Q2", " "],
[" ", " ", "Oil (Max)", "Oil (Min)", "Oil (Max)", "Oil (Min)"]
]
}
var data = {
data:[
["Constitutional monarchy", " ", "78.276", "2.946", "80.259", "5.564"],
[" ", 2012, "23.650", "23.650", "80.259", "51.127"],
[" ", 2013, "71.218", "2.946", "71.663", "47.657"],
// more arrays with cells values
]
}
var data = {
styles:[
css:{
major:{ color: "#ff00ff", background: "#0000AA", fontSize: 14 }
},
cells:[
[1,2,"major"]
]
]
}
You can export data from Pivot to the CSV format with the csv() method of the Export module. The method takes an object with export settings as a parameter:
pivot.export.csv({
name:"pivot_data", // pivot data will be exported to a CSV file named "pivot_data"
flat:true, // pivot data will be presented as a flat structure
rowDelimiter: "\t", // the tab delimiter will be used to separate rows
columnDelimiter: ";" // the semicolon delimiter will be used to separate columns
});
The csv() method returns a CSV string with Pivot data.
Back to top