我想導出一個在asp中動態創建的html表,但是當我導出到excel時,所有的td都在Excel中的單個單元格中。任何想法如何使每個TD在Excel中不同的單元格?用ASP導出html到Excel
這裏是我的代碼:
<% Set x = Server.CreateObject("MSXML2.ServerXMLHTTP")
st = "&getdata=yes"
x.Open "POST","https://www.mysite.com/exportToExcel.asp?",false
x.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
x.send st
%>
<table>
<thead><tr>
<th>Account</th>
<th>Company</th>
<th>Street Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<%
Response.ContentType = "application/excel"
Response.AddHeader "content-disposition","attachment;filename=filename.xls"
Response.Write(x.responseText)%>
</tbody>
</table>
我從來沒有做過此之前,所以請原諒我草率的編碼。
謝謝,我試過了,沒有運氣。我嘗試使用上面的方法與靜態HTML表,它的工作原理,只是沒有動態構建。 – John