4 October 2025

Using for-each@section: for Accurate Page Numbering

Advised Solutions - Business Analytics Series

for-each@section

Page numbering is a critical aspect of professional report formatting in BI Publisher when generating multi-section documents. Many organizations rely on embedded Microsoft Word page numbering features rather than the BI Publisher’s initial-page-number attribute for better formatting control across sections.

What Is for-each@section:?

The BI Publisher for-each@section: syntax is a powerful way to iterate over report sections as distinct logical groups, resetting counters or performing operations at the start of each new section in your template.

This approach enables precise control for page numbering and headers/footers which need to restart or increment per section.

Integrating With Microsoft Word Page Numbering

Microsoft Word supports dynamic page numbering fields which automatically track the current page and section pages. By combining for-each@section: loops with Word’s section breaks and page number fields, you can:

  • Reset page numbers at each new data section.

  • Display page numbers as “Page X of Y” per section instead of the entire document.

  • Have consistent page numbering without the quirks sometimes seen with BI Publisher’s built-in initial-page-number logic.

How to Use for-each@section: for Page Numbering

  1. Organize your RTF template so each logical section corresponds to a data group iterated with for-each@section:

  2. Insert Microsoft Word Section Breaks between each data section manually in the Word template to define page numbering boundaries.

  3. Place Word page number fields (Insert > Page Number > Format Page Numbers) in the header/footer within each section:

    • Choose “Start at 1” to restart numbering per section.

  4. Use the following BI Publisher syntax to loop over your sections:

				
					<?for-each@section:DATA_GROUP?>
  <!-- Your section content here -->
<?end for-each?>

				
			

Each iteration corresponds to a section in your Word template, helping Microsoft Word manage pagination correctly.

Benefits of This Approach

  • Clean separation of logical sections with individual page counters.

  • Greater flexibility for complex, multi-section reports such as contracts, statements, or multi-department summaries.

Tips

  • Always test your template output in Word to confirm page breaks and numbering behave as expected.

  • Remember that Word’s page number fields are dynamically updated when printing or generating PDFs.

  • Combine with BI Publisher page-count commands for conditional logic or custom page number display.

Summary

Using for-each@section: with Microsoft Word’s native page numbering fields is a best practice for multi-section BI Publisher reports requiring accurate, reusable page counters. This method yields professional, reliable page numbering across large, complex documents with ease.

Need some assistance?

Ready to bring clarity to customer, supplier and employee communications? With BI Publisher, we specialise in customising customer, supplier, and employee-facing documents such as invoices, purchase orders, payslips, and statements to meet your exact branding, compliance, and operational needs. From layout design to data logic enhancements, we help you deliver clear, consistent, and impactful outputs across your organization. Contact us today to discover how our expertise in BI Publisher can streamline your document processes and elevate your business communications.