ReportDocument report = new ReportDocument(); report.Load("C:/Reports/Sales.rpt"); report.SetParameterValue("startDate", DateTime.Now.AddDays(-7)); report.SetParameterValue("endDate", DateTime.Now); report.SetDatabaseLogon("username", "password"); reportViewer.ReportSource = report;
ReportDocument report = new ReportDocument(); report.Load("C:/Reports/Sales.rpt"); report.SetParameterValue("startDate", DateTime.Now.AddDays(-7)); report.SetParameterValue("endDate", DateTime.Now); report.SetDatabaseLogon("username", "password"); report.ExportToDisk(ExportFormatType.PortableDocFormat, "C:/Reports/Sales.pdf");This code does the same as the previous example, but instead of displaying the report in a `ReportViewer` control, it exports it to a PDF file. The `ExportToDisk` method takes two parameters: the export format (in this case, `PortableDocFormat` for PDF) and the output file path. Package Library: ReportDocument belongs to the Crystal Reports package library, which is part of the SAP Crystal Reports Runtime Engine for .NET Framework. This library provides developers with tools and resources to create and deliver reports in various formats, including PDF, Excel, and Word. It also includes a report designer, a report viewer control, and a set of APIs for integrating reports into .NET applications. The Crystal Reports package library is available as a separate download from the SAP website.