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

Free Support Forum - aspose.com

Next Record doesn't work as expected

We have a word document which contains Next function, this word file contains 16 blocks in one page to print labels.
If the file merge with the data (13 records) I expected 3 blocks which doesn’t have any data removed automatically. The same when I have 32 records, I expected automatically the blocks extended to second page and 32 blocks get printed. This is word standard behaviour. But none of the above scenarios happen.

I’ll attach word file.

@minaeimi Could you please ZIP and upload your source code and all input documents here to reproduce the issue? We will check the issue and provide you more information.

Here is the file:
2x8cont_IPS_2x8_Labels_(Contact).docx (21.3 KB)

@minaeimi Could you please provide code that demonstrates an issue?

This is the code we are using. we are using java library and using Servoy platform.

var table = new Packages.com.aspose.words.net.System.Data.DataTable();
//merging merged_fields in word file with data
for (var t = 0; t < tags.length; t++)
{
    /**@type {JSDataSet}*/
    var tagDataset = tags[t];
    if (tagDataset instanceof JSDataSet) {
    if (tagDataset.getMaxRowIndex() > 0)
    {
        //					doc.mailMerge(tagDataset);
        for (var td = 1; td <= tagDataset.getMaxRowIndex(); td++)
        {
            var columns = tagDataset.getColumnNames();
            var rows = tagDataset.getRowAsArray(td);
            var rowsData = []

                for (var c = 0; c < columns.length; c++)
            {
                if (!table.getColumns().contains(columns[c]))
                {
                    table.getColumns().add(columns[c]);
                    if (rows[c] instanceof Date) {
            var d = utils.dateFormat(rows[c], 'dd/MM/yyyy hh:mm')

                            rowsData.push(d);

        } else
        {
            rowsData.push(rows[c]);
        }
    }
}
table.getRows().add(rowsData);
doc.getMailMerge().execute(table);
columns = [];
rows = [];
table = new Packages.com.aspose.words.net.System.Data.DataTable();

}
}
}
}

@minaeimi
We have reproduced the issue. We will shortly create a request for its fixing. Could you please send as the documents you get when merging 13 and 32 blocks mentioned in the initial message, so that the fix could exactly meet your expectations.

@Vadim.Saltykov Thank you.
The document I already sent you also works. It contains 16 cells and if you merge it with 13 records, 3 of them remain empty.
Any estimate when the issue will be fixed?

@minaeimi When I merge using MS Word with my test data, I get this result. Do you expect to see the same?

MailMerge.png (126.9 KB)

@Vadim.Saltykov yes, it is exactly what I expected to see.
Also if the documents contains 16 cells and it merges with 43 records, I expected all those 43 records printed in other pages, page 1, 2 and 3.
And any estimation when will the issue be fixed?

@minaeimi Thank you for additional information. I have logged it as WORDSNET-23362. We will keep you informed and let you know once it is resolved.

@Vadim.Saltykov thank you. It is urgent issue for us. It would be great if you could give us and ETA.

@minaeimi We will inform you within this forum thread as soon as we have more information. We apologize for your inconvenience.

@Vadim.Saltykov Thank you

@minaeimi You can use the following option to remove extra fields from the resulting document.

document.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);

As for the question regarding insertion of 32 records, please note that Aspose.Words generates an output document similar to what MS Word generates in this case. Perhaps you were confused by the result due to the fact that there is one additional blank page in your template. Please try repeating the merge with a slightly modified template attached.
NewTemplate.docx (21.1 KB)