JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.flexmonster.com/theme/stripedblue/flexmonster.min.css" />
<button onclick="excel()">Export to ecxel</button>
<div id="pivot-container"></div>
CSS
.fm-grid-view .fm-cell,
.fm-data-sheet {
border: 0px !important;
}
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
/* toolbar: true, */
report: {
dataSource: {
type: "json",
data: getData()
},
options: {
grid: {
type: "flat",
showHeaders: false
}
}
}
});
function excel() {
pivot.exportTo("excel", {
excelSheetName: "Pivot Table",
showFilters: false
});
}
function getData() {
return [{
"Category": "Accessories",
"Size": "262 oz",
"Color": "red",
"Destination": "Australia",
"Business Type": "Specialty Bike Shop",
"Country": "Australia",
"Price": 174,
"Quantity": 225,
"Discount": 23
},
{
"Category": "Accessories",
"Size": "214 oz",
"Color": "yellow",
"Destination": "Canada",
"Business Type": "Specialty Bike Shop",
"Country": "Canada",
"Price": 502,
"Quantity": 90,
"Discount": 17
},
{
"Category": "Accessories",
"Size": "147 oz",
"Color": "white",
"Destination": "France",
"Business Type": "Specialty Bike Shop",
"Country": "France",
"Price": 242,
"Quantity": 855,
"Discount": 37
},
{
"Category": "Accessories",
"Size": "112 oz",
"Color": "yellow",
"Destination": "Germany",
"Business Type": "Specialty Bike Shop",
"Country": "Germany",
"Price": 102,
"Quantity": 897,
"Discount": 42
},
{
"Category": "Accessories",
"Size": "256 oz",
"Color": "red",
"Destination": "United Kingdom",
"Business Type": "Specialty Bike Shop",
"Country": "United Kingdom",
"Price": 126,
"Quantity": 115,
"Discount": 44
},
{
"Category": "Accessories",
"Size": "278 oz",
"Color": "yellow",
"Destination": "United States",
"Business Type": "Specialty Bike Shop",
"Country": "United States",
...