and show the rdl report by the following
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/ClientBin/Reports/" + reportFileName + ".rdlc");
DataSetName = "DatasetofReport";
PageWidth = 11.75f;
PageHeight = 9;
localReport.SetParameters(new ReportParameter("CompanyName", "Shohel LTD", true));
var DataList= which is getting from xml file or binary file
RenderRDLCReport(DataList, reportFileName, localReport);
private void RenderRDLCReport<T>(List<T> objList, string reportFileName, LocalReport localReport)
{
ReportDataSource reportDataSource = new ReportDataSource(DataSetName, objList);
//sub Report Procession
localReport.SubreportProcessing += new SubreportProcessingEventHandler(localReport_SubreportProcessing);
localReport.DataSources.Add(reportDataSource);
#region Print PDF
var reportType = "PDF";
string mimeType = string.Empty;
string encoding = string.Empty;
string fileNameExtension = string.Empty;
//The DeviceInfo settings should be changed based on the reportType
//http://msdn2.microsoft.com/en-us/library/ms155397.aspx
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>" + PageWidth.ToString() + "in</PageWidth>" +
" <PageHeight>" + PageHeight.ToString() + "in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>0.5in</MarginLeft>" +
" <MarginRight>0.5in</MarginRight>" +
" <MarginBottom>0.5in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
var renderedBytes = localReport.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
//Clear the response stream and write the bytes to the outputstream
//Set content-disposition to "attachment" so that user is prompted to take an action
//on the file (open or save)
Response.Clear();
Response.ContentType = mimeType;
Response.BinaryWrite(renderedBytes);
Response.End();
#endregion
}
No comments:
Post a Comment