<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/pivot.min.js" type="text/javascript"></script>
<script src="js/tips_data.min.js" type="text/javascript"></script>
<script src="js/jquery.table2excel.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/pivot.min.css" />
<style>
body {
font-family: Verdana;
}
</style>
</head>
<body>
<div id="output" style="overflow: scroll;width: 1000px;height: 500px;"></div>
<button id="btn">点击下载</button>
<script type="text/javascript">
var utils = $.pivotUtilities;
var heatmap = utils.renderers["Heatmap"];
var sumOverSum = utils.aggregators["Sum over Sum"];
//生成表格
$("#output").pivot(
utils.tipsData, {
rows: ["sex", "smoker"],
cols: ["day", "time"],
aggregator: sumOverSum(["tip", "total_bill"]),
renderer: heatmap
});
//下载
$('#btn').click(function() {
$(".pvtTable").table2excel({
exclude: ".noExl",
name: "Excel Document Name",
filename: "<<<<<<<<<<<",
fileext: ".xls",
exclude_img: true,
exclude_links: true,
exclude_inputs: false
});
})
</script>
</body>
</html>
网友评论