下面是導出HTML表到excel我的示例代碼:導出到ExcelĴ查詢代碼導出後在Excel中刪除0
<!DOCTYPE HTML>
<html>
<head>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" >
</script>
<script>
$(function(){
$('button').click(function(){
var dvData = $('#dvData').html();
window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
})
})
</script>
</head>
<body>
<button>
Export To Excel
</button>
<div id="dvData">
<table>
<th> ID </th>
<th> Name </th>
<tr>
<td>"1.0"</td>
<td>string1</td>
</tr>
<tr>
<td>10</td>
<td>string2</td>
</tr>
</table>
</div>
</body>
</html>
該出口1.0在Excel 1這是不對的。我嘗試添加單引號,但出現在我不想要的網頁中。
可能重複:http://stackoverflow.com/questions/25989238/exporting-html-table-with-correct-format-in-javascript – 1cgonza