reportViewer1报表打印

来源:互联网 发布:jsp连接sql的方法 编辑:程序博客网 时间:2024/04/30 02:09

if (ds.Tables[0].Rows.Count > 0)
            {
                //为报表浏览器指定报表文件
                reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";
                //显示报表
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
                reportViewer1.LocalReport.DataSources.Clear();
                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_ep01NEW", ds.Tables[0]);
                reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                reportViewer1.LocalReport.Refresh();
                reportViewer1.RefreshReport();
                //CrystalReport1 report = new CrystalReport1();
                //report.SetDataSource(ds);
                //Form2 f2 = new Form2();
                //f2.SetReportSouce(report);
                //f2.Show();

            }