Pages

Tuesday, November 25, 2014

Export anything to excel

protected void LinkProcess_Click(object sender, EventArgs e)
    {
        try
        {
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            byte[] bytes = KMIReportViewer.ServerReport.Render(
               "Excel", null, out mimeType, out encoding, out extension,
               out streamids, out warnings);

            Response.ContentType = "application/ms-excel";
            Response.OutputStream.Write(bytes, 0, bytes.Length);
            Response.AddHeader("Content-Disposition", "attachment;filename=ReviewFinding.xls");

        }
        catch (Exception)
        {
        }
    }

No comments:

Post a Comment