-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportOutput.aspx.cs
More file actions
47 lines (40 loc) · 1.61 KB
/
ReportOutput.aspx.cs
File metadata and controls
47 lines (40 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using DevExpress.XtraReports.UI;
public partial class ReportOutput : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
XtraReport report = Session["report"] as XtraReport;
if (report != null)
ExportReport(report, "report", Request.QueryString["ddlExportType"], Convert.ToBoolean(Request.QueryString["bInline"]));
else
Label1.Visible = true;
}
public void ExportReport(XtraReport report, string fileName, string fileType, bool inline) {
MemoryStream stream = new MemoryStream();
Response.Clear();
if (fileType == "xls")
report.ExportToXls(stream);
if (fileType == "pdf")
report.ExportToPdf(stream);
if (fileType == "rtf")
report.ExportToRtf(stream);
if (fileType == "csv")
report.ExportToCsv(stream);
Response.ContentType = "application/" + fileType;
Response.AddHeader("Accept-Header", stream.Length.ToString());
Response.AddHeader("Content-Disposition", (inline ? "Inline" : "Attachment") + "; filename=" + fileName + "." + fileType);
Response.AddHeader("Content-Length", stream.Length.ToString());
//Response.ContentEncoding = System.Text.Encoding.Default;
Response.BinaryWrite(stream.ToArray());
Response.End();
}
}