[英]Programmatically trigger export and print commands in report viewer
由于我无法在asp.net中截获报告查看器的“打印”和“导出”事件( 我之前的问题 )。 我现在正在考虑使用按钮以编程方式触发这两个功能。
有没有人能够在报表查看器asp.net中实现这一目标? 我的意思是在报表控件中将这些控件设置为不可见时触发“打印”和“导出为pdf”?
ReportViewer1.PrintDialog()似乎可以工作。 我不确定出口。
出口:
private void DoExport(string exportType) {
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string filename;
byte[] bytes = reportViewer.LocalReport.Render(
exportType, null, out mimeType, out encoding,
out extension,
out streamids, out warnings);
filename = string.Format("report-{0:yyyy-MM-dd}.{1}", DateTime.Now, extension);
Response.ClearHeaders();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
Response.ContentType = mimeType;
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
protected void btnExportToExcel_Click(object sender, EventArgs e) {
DoExport("Excel");
}
protected void btnExportToPdf_Click(object sender, EventArgs e) {
DoExport("Pdf");
}
不确定打印(如何在服务器上触发客户端功能?;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.