Search code examples
c#crystal-reportsconsole-application

Launch a Crystal Report from a C# console application


I have written a report is C# using a CrystalReportForm. I wrote this as a Windows Forms Application. (Visual Studio 2015).It works well but I need to convert this to a console application so I can automate it.

I used the CrystalReportViewer and possibly this is not the best approach. Any assistance/direction is appreciated.

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.         

Solution

  • This question shows my ignorance in Crystal with C#. It was an easy fix. Just had to load the document and not reference it through the viewer.