I am attempting to load multiple sub-reports into a master report document. The process is:
- Use the RAS SDK to obtain a reference to the detail area
- Add a section to the detail area
- Import the subreport into the detail area
The code is pretty simple as well.
privateReportDocument AddSubReportToParent(string subReportName, string fileName)
{
try
{
CrystalDecisions.ReportAppServer.ReportDefModel.ISCRArea detailArea = _crystalDocument.ReportClientDocument.ReportDefController.ReportDefinition.DetailArea;
CrystalDecisions.ReportAppServer.ReportDefModel.Section section =new CrystalDecisions.ReportAppServer.ReportDefModel.Section();
string sectionName ="Section"+ subReportName.Replace(".", "");
section.Name = sectionName;
section.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindDetail;
section.Width = headerArea.Sections[0].Width;
_crystalDocument.ReportClientDocument.ReportDefController.ReportSectionController.Add(section, detailArea, -1);
_crystalDocument.ReportClientDocument.SubreportController.ImportSubreport(subReportName, _configSettings.InputPath +"\\"+ fileName, section);
ReportDocument subreport = _crystalDocument.OpenSubreport(subReportName);
return subreport;
}
catch (Exception ex)
{
Logger.ErrorException(this.GetReportBuilderErrorText(this.GetReportBuilderErrorText(String.Format("Unable to add subreport '{0}' from file {1} to custom Crystal Report", subReportName, fileName))), ex);
throw;
}
}
However, when I attempt to load the 41st report (or sometimes greater) the ImportSubreport method throws an exception with the message, "Invalid Section Height". Note that I have one section for each report. This is to make it easier to place the subreport on in the document and on it's own page.
I cannot seem to determine what is going wrong. Why would the 41+ import fail?
I am using Crystal Reports Version for Visual Studio .NET, 13.0.8.