We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Incomplete Print in Word table

As described in the attached file, I try to print labels on a Word template having 8 block (4 column and 2 rows), each block consists of 2 cells containing the mergefield Field1 and Field2.
The data are passed by DataTable. If in one row a the datavalue printed in the first cell (Field1)
is null, empty or blank, the programm stops printing inside the actual block, and continues printing in the next block. Therefore the printing is incomplete in this case.
The consequence is that I have to print as many block as one row contains (4, 8 etc.), otherwise I’m missing data in the generated Worddocument
any Idea?

Thanks for your inquiry. The reason is NEXT field before MERGEFIELD FIELD1. When you insert values during mail merge you loop through cells in the row. So you insert value of fourth record of your datatable into the first FIELD2. You can see this using the following code.

public void TestMailMerge_110884()
    Document doc = new Document("in.doc");
    DataTable dt = GetDataTable_110884();
private DataTable GetDataTable()
    DataTable dt = new DataTable("myTable");
    for (int j = 1; j <= 7; j++)
        DataRow dr = dt.NewRow();
        dr["FIELD1"] = "label_1." + j.ToString();
        dr["FIELD2"] = "label_2." + j.ToString();
    return dt;

You can try inserting FIELD1 and FIELD2 into the same cell to solve this problem. For example see attached document.
Best regards.

Thank for your quick answer, with this new Template the printing is working well.