Multi merge

Hi ,

While generating single merge document , i have a template that set-up with 5 rows of temp data and save.

Now my SQL returns only 3 rows. Now wheni try to generate the
multimerge the new 3 rows getting appended and the remaining 2 rows not getting deleted.(old template data has 5 rows now the doc contains New row 3 + old temp data 2)

please let me know your views to solve this issue

WordMergeDocument wordMergeDocument = new WordMergeDocument(new File(argCvd.MergeDocument));
if (argRowCount == 1)
{
    wordMergeDocument.mergeFields(argColumnMap);
}
else
{
    WordMergeDataSource dataSource = new WordMergeDataSource(argColumnMap, argRowCount);
    wordMergeDocument.mergeFields(dataSource);
}
if (argOutputStream == null)
{
    FileOutputStream outputStream = new FileOutputStream(argDosPath);
    outputStream.write(wordMergeDocument.generateDocument(argDosPath.substring(argDosPath.lastIndexOf(".") + 1)));
    outputStream.close();
}
else
{
    argOutputStream.write(wordMergeDocument.generateDocument(argDosPath.substring(argDosPath.lastIndexOf(".") + 1)));
    argOutputStream.close();
}

------------------------

public WordMergeDocument(File argFilePath) throws Exception
{
    originalDocument = new Document(argFilePath.getPath());
    appendDocument();
}

public void appendDocument() throws Exception
{
    if (currentDocument != null)
    {
        documentsList.add(currentDocument);
    }
    currentDocument = originalDocument.deepClone();
    currentBuilder = new DocumentBuilder(currentDocument);
}

-------------------------

public void mergeFields(IMailMergeDataSource argIMailMergeDataSource) throws Exception
{
    currentDocument.getMailMerge().execute(argIMailMergeDataSource);

}

Regards,
Karthick

Hi

Thanks for your inquiry. I think, in your case, you should use Mail Merge with regions. Please see the following link for more information:
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
Please let me know in case of any issues, I will be glad to help you.
Best regards,

Hi Andrey,

Is it possible to have a live chat with you now?

Regards,
Karthick

The Following Piece of code solved my problem

doc.getMailMerge().deleteFields();

Regards,
Karthick.k