Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I convert an html table to an Excel File?
    primarykey
    data
    text
    <p>I'm trying to get my page Data.aspx to return an html table, but I want that table to be in an excel format. This is my code so far.</p> <p>In the Data.aspx Load:</p> <blockquote> <p>Response.Clear()</p> <pre><code> Select Case lstrCmd Case "summary" Response.Write(Summary()) Response.Cache.SetCacheability(HttpCacheability.NoCache) Case "export" Response.ContentType = "application/ms-excel" Response.AddHeader("Content-Disposition", "attachment;filename=" &amp; _ mstrProjectName &amp; ".xls") Response.Write(SummaryExport()) End Select Response.End() </code></pre> </blockquote> <p>So the add header is where I'm puzzled. This is something another peice of my software uses, but I'm not sure if it will work.. </p> <p>the jquery that calls this is using ajax:</p> <blockquote> <pre><code> function btnSubmitExport_Click() { var compID = $("#ddlCompanies").val(); var projectID = $("#ddlProjects").val(); var startDate = $("#txtStartDate").val(); var endDate = $("#txtEndDate").val(); var compName = $("#ddlCompanies :selected").text(); var projectName = $("#ddlProjects :selected").text(); </code></pre> </blockquote> <pre><code> $("#content").html("&lt;div class='loading'&gt;loading...&lt;/div&gt;"); $.ajax({ url: "Data.aspx", data: { CompanyID: compID, ProjectID: projectID, CompanyName: compName, ProjectName: projectName, StartDate: startDate, EndDate: endDate, Cmd: "export" }, success: function(html) { $("#content").html(html); }, error: function(response) { alert(response); } }); } </code></pre> <p>So, typically, when I request this data, I just throw the resulting html into a "content" div on my default.aspx page.. but I want that html to be an excel file! </p> <p>Any hints or thoughts on this would be helpful. </p> <p>I see the same question in other places, but not any answers that help me with my existing code.. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload