Number of records are missed when NEXT field is used in mail merge template using .NET

Hi,



We have some problems with the NEXT field when merging a document with our data.

We have a word table with each cell containing a row of data.

When placing the “next” at the end of the first cell we get a number of missing rows.

When placing the “next” at the beginning of the next cell we get the right amount of data.



We would like both ways to work the same as users might not notice this error until they accidently stumble on the fact that they are missing some data in their documents.



I’ve added a test project with some test data and test documents showing you how to reproduce the error.



Thanks in advance for looking into this!



Kind regards,



Kris

Hi Kris,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you perform the mail merge process by using MS Word, you will get the same output.

In your both cases, the behavior of Aspose.Words is correct. Please insert a Next field after the first set of merge (MergeField) fields in the main document; otherwise, Word skips merging the first data record. Please read more detail about Next field from here:

Hope this answers your query. Please let us know if you have any more queries.

Ok, sorry and thanks.

Hi Kris,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

@krisg

Starting from Aspose.Words 16.8, we added support of NEXT field to LINQ Reporting Engine. Now, you can instruct the engine to force movement to the next item within a data band using a next tag. This feature is useful in label-print-like scenarios when you need to output data about a fixed number of items in a single table row like in the following example. Given that Clients is a DataTable instance having a field named “Name”, you can use the following template to output three client names per table row while outputting names of all clients in a single table.

<<foreach [c in Clients]>>
<<[c.Name]>><<next>><<[c.Name]>><<next>><<[c.Name]>> 
<</foreach>>