我已经写了一个使用CrystalReportForm的C#报告。我将其作为Windows窗体应用程序编写。(Visual Studio2015).It运行良好,但我需要将其转换为控制台应用程序,以便实现自动化。
我使用了CrystalReportViewer,这可能不是最好的方法。任何帮助/指导都将不胜感激。
DSP = new Classes.DSP_Object(txtStartDate.Text);
var crf = new CrystalReportForm();
var dsp = new CrystalReports.DSP_Report();
((TextObject)dsp.ReportDefinition.Sections["Section1"].ReportObjects
["lblWeekOfHeader"]).Text = DSP.lblWeekOfHeader;
//Lots more assignments of object fields to report
.
.
.
crf.crv1.ReportSource = dsp;
crf.Show();
//The report looks great at this point. 发布于 2020-06-11 02:31:48
这个问题显示了我对C#水晶的无知。这是一个很容易解决的问题。只需加载文档,而不是通过查看器引用它。
发布于 2020-05-27 02:43:55
因为您需要从控制台应用程序运行它,所以我不会尝试在控制台应用程序中托管一个查看器-这是行不通的。
相反,您可以从控制台应用程序运行报告,另存为pdf并显示pdf。
生成报告后,您可以执行以下操作:
Process p=new Process();
p.StartInfo.FileName = @"G:\GeneratedCrystalReport.pdf";
p.Start();https://stackoverflow.com/questions/62029027
复制相似问题