//先读取table的HTML
var tableHtmlStr = '<table class="table"><tr><td>1</td><td>2</td></tr></table>';
//敲黑板!!! 解决导出的excel中网格先消失的问题 (给table加样式 vnd.ms-excel.numberformat:@;)
var excelHtml = '<html xmlns:x="urn:schemas-microsoft-com:office:excel"><head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:WorksheetOptions><x:Print><x:ValidPrinterInfo /></x:Print></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml></head><style>table{vnd.ms-excel.numberformat:@;}</style>'+tableHtmlStr +'</html>;
var temp = {hello: 'world'};
var blob = new Blob([JSON.stringify(temp, null, 2)],{type : 'application/json'});
//将excelHtml 传入
var excelBlob = new Blob([excelHtml ], {type: 'application/vnd.ms-excel'});
var oA = document.createElement('a');
// 利用URL.createObjectURL()方法为a元素生成blob URL
oA.href = URL.createObjectURL(excelBlob);
oA.download = '这是excel文件名称'+ '.xls';
// 模拟点击
oA.click();