【发布时间】:2022-01-16 15:11:38
【问题描述】:
我可以通过 OpenFileDialog 导入水晶报表的 .rpt 和 .cs 文件,但我不知道如何使用它来生成报表。是否可以只导入 .rpt 和 .cs 并使用导入的文件生成报告?
【问题讨论】:
标签: c# crystal-reports
我可以通过 OpenFileDialog 导入水晶报表的 .rpt 和 .cs 文件,但我不知道如何使用它来生成报表。是否可以只导入 .rpt 和 .cs 并使用导入的文件生成报告?
【问题讨论】:
标签: c# crystal-reports
添加对水晶报表 SDK (CrystalDecisions.CrystalReports.Engine) 的引用 https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads
然后打开报告
using (ReportDocument rep = new ReportDocument())
{
//Open report
rep.Load("SomeReport.rpt", OpenReportMethod.OpenReportByTempCopy);
//rep.PrintOptions = ...
rep.PrintToPrinter(1 /*NumCopies*/, true, 1, 9999);
//or
rep.ExportToDisk(ExportFormatType.PortableDocFormat, "SomeReport.pdf");
}
这假设报表知道从哪里获取数据。手动提供数据需要额外的步骤。
【讨论】: