public void renderRDL(string type, String rpath ,params ReportDataSource[] rds)
{
ReportViewer rv = new ReportViewer();
rv.LocalReport.ReportPath = rdlPath;
foreach (ReportDataSource rs in rds)
{
rv.LocalReport.DataSources.Add(rs);
}
rv.ID = "myrpt";
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo = "";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes =
rv.LocalReport.Render(type, deviceInfo,out mimeType, out encoding, out
fileNameExtension, out streams, out warnings);
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType
= mimeType; HttpContext.Current.Response.HeaderEncoding =
System.Text.Encoding.GetEncoding("big5"); //中文檔名時加此不會變亂碼HttpContext.Current.Response.AddHeader("content-disposition",
"attachment; filename=我的表." +
fileNameExtension); HttpContext.Current.Response.BinaryWrite(renderedBytes);
HttpContext.Current.Response.End();
}
}