Beispiel #1
0
    protected void btn6_Click(object sender, EventArgs e)
    {
        // Clear all content output from the buffer stream
        Response.ClearContent();
        // Specify the default file name using "content-disposition" RESPONSE header
        Response.AppendHeader("content-disposition", "attachment; filename=notice.xls");
        // Set excel as the HTTP MIME type
        Response.ContentType = "application/excel";
        // Create an instance of stringWriter for writing information to a string
        System.IO.StringWriter stringWriter6 = new System.IO.StringWriter();
        // Create an instance of HtmlTextWriter class for writing markup
        // characters and text to an ASP.NET server control output stream
        HtmlTextWriter htw6 = new HtmlTextWriter(stringWriter6);

        GridView7.RenderControl(htw6);
        Response.Write(stringWriter6.ToString());
        Response.End();
    }