Flexmonster Demo - Export to Excel Button
by Iryna Kulchytska
HTML
<script src="https://s3.amazonaws.com/flexmonster/2.2/flexmonster.js"></script>
<div id="btn-export-excel"><a onclick="exportHandler()" href="javascript:void(0)"><span>To Excel</span></a></div>
<div id="pivot-content"></div>
CSS
#btn-export-excel {
position: relative;
width: 57px;
height: 78px;
background: #FFFFFF;
cursor: auto;
}
#btn-export-excel > a {
display: block;
height: 76px;
background-size: 45px 45px;
background-position: center 10px;
background-repeat: no-repeat;
font-family: Tahoma, Arial, sans-serif;
font-size: 11px;
color: #333333;
text-align: left;
padding: 0;
margin: 0;
font-weight: normal;
text-shadow: none;
background-image: url(https://www.flexmonster.com/flexmonster/toolbar/img/toolbar/menu_xls_large.png);
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
#btn-export-excel > a {
background-image: url(https://www.flexmonster.com/flexmonster/toolbar/img/toolbar/[email protected]);
}
}
#btn-export-excel > a > span {
position: absolute;
top: 52px;
line-height: 10px;
left: 0;
right: 0;
text-align: center;
}
JavaScript
function exportHandler() {
pivot.exportTo('excel');
};
var pivot = flexmonster.embedPivotComponent("https://s3.amazonaws.com/flexmonster/2.2/", "pivot-content", "100%", "600",
{
configuratorActive: false,
data: [{
"Color": "red",
"Price": 174
}, {
"Color": "blue",
"Price": 15
}],
viewType: "grid",
rows: [{uniqueName: "Color"}],
columns: [{uniqueName: "[Measures]"}],
measures: [{uniqueName: "Price"}],
licenseKey: "Z53G-1T1WC3-1V1M-0L12-2M0A-1233-1I0Y-2Y2Q-1903-322S-0T2C-1I"
},
true);