Working with Crystal Reports ‘Report Options’ through Crystal Reports InProc RAS .NET SDK.
The very important and frequently used features in the Crystal Designer are the ReportOptions.
Consider a scenario where you would need to access / modify the values of Report Options of a Crystal report at runtime in a Crystal Reports .NET application.
In this case we would need to use the Inproc RAS APIs of Crystal Reports.
‘Report Options’ could be found at below places in the Crystal Designer.
Crystal Reports 2008 – “FILE –> Report Options”
Crystal Reports for Visual Studio 2010 – “Crystal Reports –> Report –> Report Options. “
Not all but few of these values are accessible using InProc RAS .NET APIs.
Here is how…
Take a look at the “ ReportOptions Class provided by CrystalDecisions.ReportAppServer.ReportDefModel Namespace” in the API reference Guide for InProc RAS .NET SDK.
Crystal Reports 2008 InProc RAS .NET SDK API reference guide.
Crystal Reports for Visual Studio 2010 InProc RAS .NET SDK API reference guide
Here is the sample code to demonstrate the use of these APIs.
CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ISCDReportClientDocument rcd = new ReportClientDocumentClass();
rd.Load(Server.MapPath("ReportOptionsSampleReport.rpt"));
rcd = rd.ReportClientDocument;
CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions OReportOptions = rcd.ReportOptions;
OReportOptions.CanSelectDistinctRecords = true;
OReportOptions.ConvertNullFieldToDefault = true;
OReportOptions.ConvertOtherNullsToDefault = true;
OReportOptions.EnableAsyncQuery = false;
OReportOptions.EnablePushDownGroupBy = true;
OReportOptions.EnableSaveDataWithReport = true;
OReportOptions.EnableSelectDistinctRecords = true;
OReportOptions.ErrorOnMaxNumOfRecords = true;
OReportOptions.RefreshCEProperties = true;
rcd.SaveAs("NewCrystalReport.rpt", @"C:\");
These APIs could be really usefull specially while plaiyng with the report object on the fly and edit / modify the report options of the target rpt file.