2 Answers, 1 is accepted
The report book functionality is combining different reports into one for the purposes of printing them at once or exporting them to a single file. Reports are displayed in the order they were added to the report book, but they do not become one in the sense of sharing sections or data. You would have to create the same page sections for each report that would be added to the report book in order to achieve your inquiry.
Regards,
Steve
the Telerik team
I know this question is 12+ years old, but I found myself looking for the same functionality.
There are two different ways you can accomplish this, but it requires some out-of-the-box thinking.
1) Have a method that will programmatically create your header, and use that function for all the reports in the report book. This is a bit tedious and doesn't provide the visual support that the Telerik Report Designer provides.
public void CreatePageHeader(Telerik.Reporting.Report report)
{
var pageHeaderSection = GetItem<PageHeaderSection>(report.Items, "PageHeaderSection");
var headerTextBox = new TextBox
{
Location = new PointU
{
X = new Unit(4.1, UnitType.Inch),
},
Size = new SizeU
{
Width = new Unit(2.889, UnitType.Inch),
Height = new Unit(0.3, UnitType.Inch)
}
};
headerTextBox.Name = "HeaderTextBox";
headerTextBox.CanGrow = true;
headerTextBox.Style.Font.Size = new Unit(20, UnitType.Point);
headerTextBox.Style.Font.Bold = true;
headerTextBox.Style.TextAlign = HorizontalAlign.Right;
pageHeaderSection.Items.Add(headerTextBox);
}
2) Create a Header_Template.trdp and add your header components to it. Then programmatically copy the items from that header template, to each of the reports in the report book. This allows you to manage your header template in the Telerik Report Designer, and makes it easier to change it as opposed to the first approach I presented.
public void CopyHeaderTemplate(Telerik.Reporting.Report report)
{
var headerTemplate = OpenReportTemplate("Header_Template.trdp");
var headerTemplatePageHeaderSection = GetItem<PageHeaderSection>(headerTemplate.Items, "PageHeaderSection");
var reportTemplatePageHeaderSection = GetItem<PageHeaderSection>(report.Items, "PageHeaderSection");
foreach (var item in headerTemplatePageHeaderSection.Items)
{
reportTemplatePageHeaderSection.Items.Add(item);
}
}
Please note that the GetItem<T>() method (used in both code examples above) is a helper method I created...
public T GetItem<T>(ReportItemBase.ItemCollection items, string itemName) where T : ReportItemBase
{
if (items is null)
throw new ArgumentNullException(nameof(items));
if (string.IsNullOrWhiteSpace(itemName))
throw new ArgumentNullException(nameof(itemName));
var item = items[itemName];
if (item is null)
throw new Exception($"Unable to reference [{itemName}]");
return (T)item;
}
Thank you for sharing those approaches with the community!
I would also like to mention that if using a ReportBook is not a must, the desired functionality may be achieved using the SubReport Item. It does not render the page sections of the inner report, so the page header section of the main report will be rendered instead on each page.