Linq Reporting - Is it possible to use data source values in page footer?

The scenario:

We are generating invoices.
There is a “for each” loop in the body of the word document with a page break, meaning each invoice should start in a new page. However, a single invoice may have too many line items and span through multiple pages.

The idea is to have the invoice number in the page footer as well.
The attached template will give will an idea of what I’m trying to accomplish, I’m wondering if this is even possible.

Thanks in advance.

SampleTemplateFooter.zip (11.4 KB)

@ebrito,

This does not seem to be an easy use-case; however, we are checking this scenario and will get back to you as soon as possible.

@ebrito,

Please check these template/output Word documents (Invoices_Template.zip (23.5 KB)) and try running the following code:

List<List<string>> invoices = new List<List<string>>();
for (int i = 0; i < 3; i++)
{
    invoices.Add(new List<string>());
    for (int j = 0; j < 50; j++)
        invoices[invoices.Count - 1].Add("Item " + (j + 1));
}

Document doc = new Document("E:\\temp\\Invoices.docx");

ReportingEngine engine = new ReportingEngine();
engine.Options |= ReportBuildOptions.RemoveEmptyParagraphs;
engine.BuildReport(doc, invoices, "invoices");

doc.UpdateFields();

doc.Save("E:\\temp\\19.11.docx"); 

I think, this is the simplest way to meet your requirement. In this case, updating of fields is required. And also note how fields are used in the template. Hope, this helps.

Thanks. I see a field in the footer what I cannot understand is is connected to the data. Would you mind explaining?

When I open the word the field reads: “Error, reference source not found.”
If I right click on it, “Edit Field” is not available. If I click on “Toggle Field Codes” then I see:

{ REF "page1invoice" }

@ebrito,

Yes, you are right. But, after when ReportingEngine.BuildReport executes then calling the Document.UpdateFields method will dynamically calculate the correct value of REF field in footer.