由于我无法拦截asp.net(my previous question)中报告查看器的“打印”和“导出”事件。我现在正在考虑使用按钮以编程方式触发这两个函数。
有没有人能够在报告查看器asp.net中实现这一目标? 我的意思是在报表查看器中触发“打印”和“导出为pdf”,这些控件设置为不可见?
答案 0 :(得分:0)
ReportViewer1.PrintDialog()似乎有效。我不确定出口。
答案 1 :(得分:0)
导出:
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");
}
不确定打印(如何在服务器上触发客户端功能?;)