2011-06-23 11 views
1

aspで動的に作成されたhtmlテーブルをエクスポートしようとしていますが、excelにエクスポートするとすべてのtdがExcelの単一セルにあります。任意のアイデアはどのようにExcelで別のセルを各tdにするには?ここでASPを使用した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> 

ので、私のずさんなコーディングを言い訳する前に、私はこれをやったことがありません。

答えて

0

はこれを試してみてください:

Response.Clear

Response.ContentTypeの=「アプリケーション/ vnd.m S-エクセル」

Response.addHeader "コンテンツ・処分"、 "添付ファイルは、このことができますファイル名= yourname.xls"

希望。

+0

ありがとうございました。私はそれを試しましたが、運はありません。私は静的なhtmlテーブルで上記のメソッドを使用してみましたが、それは動作しますが、動的に構築されたものではありません。 – John

関連する問題