报告数据导出到Excel。 [英] Report Data export to excel.

查看:70
本文介绍了报告数据导出到Excel。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 如何将报表查看器中的报表数据导出为自定义asp.net按钮单击的Excel。我正在使用Visual Studio 2013。

 How to export Report data in Report Viewer to excel from custom asp.net button click. I am using Visual Studio 2013.

Ravindranath

Ravindranath

推荐答案

嘿Ravindranath,这应该是非常直接的。在按钮的单击事件中,您可以执行类似于以下操作的操作,将报表呈现为字节流,然后将其写入HttpResponse输出:

Hey Ravindranath, this should be pretty straight forward to do. In the click event of your button you can do something similar to the following to Render the report to a byte stream and then write it to the HttpResponse output:

        byte[] reportBytes = this.ReportViewer1.ServerReport.Render("EXCELOPENXML");

        this.Response.Clear();
        this.Response.Buffer = true;
        this.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        this.Response.AddHeader("content-disposition", @"attachment;filename=""report.xlsx""");
        this.Response.BinaryWrite(reportBytes);
        this.Response.End();


如果这不适合你,请告诉我。谢谢!
$

Let me know if this doesn't work for you. Thanks!


这篇关于报告数据导出到Excel。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆