Export to excel

Asked

Viewed 26 times

0

Good morning. I created a gridview with data from a table When I run the function to generate the Excel spreadsheet, nothing happens, could anyone give a help in what might be happening? follows code

private void ExportaExcel()
{
    string Arquivo = "RelNovosFuncionarios.xls";
    string attachment = "attachment; filename=" + Arquivo;

    Response.ClearContent();
    Response.AddHeader("content-disposition", attachment);
    Response.ContentType = "application/ms-excel";

    System.IO.StringWriter sw = new System.IO.StringWriter();

    HtmlTextWriter htw = new HtmlTextWriter(sw);

    gvClientes.RenderControl(htw);

    Response.Write(sw.ToString());
    Response.End();
}

public override void VerifyRenderingInServerForm(Control control)
{
}

1 answer

0

As there were no answers, the solution was on the _load page

put the instruction Scriptmanager.Getcurrent(this). Registerpostbackcontrol(btnGeraExcel);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.