Select all data in a DataTable dt which you want to display in Report than make a form to display report FrmReportShow,put a CrystalReportViewer on it.
Insert a Crystal Report Report1 and a DataSet1 in your application and create a DataTable1 in Dataset1 and insert all columns that you want to display on report than set crystal report datasource to dataset1.
DataSet1 d = new DataSet1();
Report1 objRpt=new Report1();
foreach (DataRow dr in dt.Rows)
{
d.DataTable1.Rows.Add(dr.ItemArray);
}
FrmReportShow frs = new FrmReportShow();
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
discreteval.Value = "Transferred";
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
frs.crystalReportViewer1.ParameterFieldInfo = paramfields;
objRpt.SetDataSource(d);
frs.crystalReportViewer1.ReportSource = objRpt;
frs.crystalReportViewer1.Refresh();
objRpt.SetParameterValue("ReportType", "Not Transferred");
//Export Report to HTML
objRpt.ExportToDisk(ExportFormatType.HTML40, Application.StartupPath + "\\Report\\Report.html");
frs.Show();
-------------------------------
if have any query than ask.
Thanks.
No comments:
Post a Comment