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.
@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.
@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)
@Vadim.Saltykov actually this solution doesn’t work for us, because it removes all unused fields which we don’t want it happens.
Any update when WORDSNET-23362 will be ready?
@minaeimi The issue WORDSNET-23362 was closed as Not a Bug
. Could you please describe the problem in more details and let us know what merge fields you need to preserve and why?
The reason is user want to see the tag as a place holder even if there is no data for it, adding following line will remove the unused fields.
document.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
@minaeimi Thank you for additional information, but it looks like your requirements are self excluding. Initially your requirements was this:
i.e. your requirement was to remove unused field after executing mail merge.
And your new requirement is to preserve unmerged field as is, which is actually the default Aspose.Words behavior.
Could you please clarify the above and if possible provide input document, code, output and expected output os we can better understand your requirements.