<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="../jQuerylib/jquery.js" type="text/javascript"></script>
<script src="../jQuerylib/jquery.base64.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#myButtonControlID").click(function(e) {
var dt = new Date();
var year = dt.getFullYear().toString();
var month = dt.getMonth() + 1;
var day = dt.getDate();
var hour = dt.getHours();
var mins = dt.getMinutes();
var postfix = year + month + day + "_" + hour + "." + mins;
var a = document.createElement('a');
//getting data from our div that contains the HTML table
var data_type = 'data:application/vnd.ms-excel';
var table_div = document.getElementById('MyTable');
var table_html = table_div.innerHTML .replace(/ /g, '%20');
a.href = data_type + ', ' + table_html;
//setting the file name
a.download = 'JDC_mon_' + postfix + '.xls';
//triggering the function
a.click();
//just in case, prevent default behaviour
e.preventDefault();
});
});
感谢