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>
<button onClick="exportToExcel()">Export to Excel</button>
<div id="pivot-container"></div>
JavaScript
function exportToExcel() {
pivot.exportTo('excel', {useCustomizeCellForData: false});
}
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
customizeCell: customizeCellFunction,
report: {
"dataSource": {
"dataSourceType": "csv",
"filename": "https://cdn.flexmonster.com/data/data.csv"
},
"slice": {
"rows": [{
"uniqueName": "Country"
}, {
"uniqueName": "Business Type"
}],
"columns": [{
"uniqueName": "Color"
}, {
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Quantity",
"aggregation": "percentofcolumn"
}],
"expands": {
"expandAll": true
},
"drills": {
"drillAll": true
}
}
}
});
function customizeCellFunction(cell, data) {
if (data.type == "value" && !data.isDrillThrough) {
if (data.value < 5) {
cell.text = "<img src='https://www.flexmonster.com/images/very-low.png' srcset='https://www.flexmonster.com/images/very-low.png 1x, https://www.flexmonster.com/images/very-low@2x.png 2x' class='centered'>";
} else if (data.value >= 5 && data.value < 10) {
cell.text = "<img src='https://www.flexmonster.com/images/low.png' srcset='https://www.flexmonster.com/images/low.png 1x, https://www.flexmonster.com/images/low@2x.png 2x' class='centered'>";
} else if (data.value >= 10 && data.value < 25) {
cell.text = "<img src='https://www.flexmonster.com/images/middle.png' srcset='https://www.flexmonster.com/images/middle.png 1x, https://www.flexmonster.com/images/middle@2x.png 2x' class='centered'>";
} else if (data.value >= 25 && data.value < 50) {
cell.text = "<img src='https://www.flexmonster.com/images/high.png' srcset='https://www.flexmonster.com/images/high.png 1x, https://www.flexmonster.com/images/high@2x.png 2x' class='centered'>";
} else if (data.value >=...