oRpt.SetDataSource(myDS) ' 设定水晶报表的ReportSource CrystalReportViewer1.ReportSource = oRpt End Sub C#代码: private void BindReport() { string strProvider = "Server=(local);DataBase=pubs;UID=sa;PWD="; CrystalReport1 oCR = new CrystalReport1(); Dataset1 ds = new Dataset1(); SqlConnection MyConn = new SqlConnection(strProvider); MyConn.Open(); string strSel = "Select * from Stores"; SqlDataAdapter MyAdapter = new SqlDataAdapter(strSel,MyConn); MyAdapter.Fill(ds,"stores"); oCR.SetDataSource(ds); this.CrystalReportViewer1.ReportSource = oCR; } 注意:在上面的代码中,你得注意一下oRpt是"Strongly Typed"的报表文件。如果你需要使用"UnTyped"报表,你得使用ReportDocument对象,然后再调用报表文件。 运行你的程序。 11) 运行你的程序 将报表文件导出成为其它格式
你能够将报表文件导出成为下列格式: 1. PDF (Portable Document Format) 1. 2. DOC (MS Word Document) 2. 3. XLS (MS Excel Spreadsheet) 3. 4. HTML (Hyper Text Markup Language – 3.2 or 4.0 compliant) 4. 5. RTF (Rich Text Format)
使用Pull模式导出报表
上一篇:在 ASP.NET 中用匿名委托简单模拟 AOP 做异常和日志处理
下一篇:存储过程使用技巧
|