Click Here For MCQ

Sunday, June 21, 2020

crystal report in asp.net mvc

Crystalreport >> Blank report  

file explorer >> database Fields(right click) >>database Export>> Project Data>> >.Net Object>>Select your related Model and selected table >> ok

Now  database Fields >>Crystalreport.model(Fields)>>by mouse drop your fields in section3 Deatils  



cshtml


this link is given at any location on your page   


<a class="btn btn-success" href="@url.action("exportReport")">Download Report</a>




public actionresult exportReport()
{
ReportDocument rd=new reportDocument();
rd.Load(Path.Combine(Server.Mappath("-/Report"),"CrystalReport.rpt"));
rd.SetDataSource(db.Tbl_Employee.toList());
response.buffer=false;
response.ClearContent();
response.clearheader();
try
{
stream Stream =rd.Exporttostream(crystaldecision.Shared.ExportFormatType.PortableDocForma);
}
catch
{
throw;
}


}

No comments:

Post a Comment