Sections and Pages

You can think of sections as logical pages that will transform into one or more physical pages during report generation. Sections contain elements (objects) that can spread over multiple pages, like TextFields and tables, so it is up to element data content whether section transforms into one or many pages. Section is always transformed into at least one physical page.

Using sections allows creating multiple page reports. Sections are not logicly tied with each other in any way, except being in the same report. If you create report that will have multiple pages for sure, use as many sections as you need in your report.

Sections always perform page-break operation. You can not have physical page with objects from two or more sections.

TextField, RichText and StyledTable can produce multiple pages from one section. PictureBoxes and ChartBoxes do not spread over physical pages. The key properties that cause producing multiple pages are TextField.OverflowTextHandling, RichText.OverflowTextHandling and StyledTable.DataSource. For detailed information see TextField, RichText and StyledTable.

 

Dynamic sections

Named sections can be added to report in a dynamic fashion, during runtime. Only sections that have Name defined can behave in this manner. To repeat sections use the RepeatSection(string sectionName, int numberOfClones) method. Assume we are using masterdetail.xml report with section named "Detail" and parameter "test" in it:

// C# code
Stampa.ReportDocument document = new Stampa.ReportDocument();

// set .xml file for printing
document.setXML("masterdetail.xml");

Section[] sections = document.RepeatSection("Detail", 5);

for (int i=0;i<sections.Length;i++)
{
	Section section = sections[i];

	Hashtable sectionParameters = new Hashtable();
	sectionParameters.Add("test","testValue");
	section.SetParameters(sectionParameters);

	... // here we create and prepare DataTable dataTable with proper data for section

	section.AddData(dataTable);	
}

// print preview
printPreviewDialog1.Document = document;
printPreviewDialog1.PrintPreviewControl.Zoom = 1.0;
printPreviewDialog1.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog(this);
	

You can add data to dynamic section using following methods :

Data set using section methods override data set using document AddXXX methods !!!