62,073
社区成员
发帖
与我相关
我的任务
分享
利用RDLC做了一个报表,系统导出自带了3中格式,现在只需要导出PDF,目前已经把Excel和Word按钮隐藏了,但还是要先点一下那个导出,然后弹出PDF。想做到不要那个下拉小三角,点击导出后直接就导出PDF,不用点两次。请大侠指教,谢谢。
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet", ds.Tables["sql"]));
ReportViewer1.DataBind();//你的代码应该到这都有
this.ReportViewer1.ServerReport.Refresh();
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] reportBytes = this.ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("报表名称" + ".pdf"));
Response.AddHeader("Accept-Header", reportBytes.Length.ToString());
Response.ContentType = "application/pdf";
Response.OutputStream.Write(reportBytes, 0, reportBytes.Length);
Response.Flush();
Response.Close();