Problem with table start- table end and blank pages with the mail merge

Hi Burepalli,

Thanks for your inquiry. In your case, please ignore my last code to remove empty paragraphs except page break.

Please use MailMerge.CleanupOptions with MailMergeCleanupOptions.RemoveEmptyParagraphs flag to remove empty Paragraphs. I suggest you please read following documentation link for your kind reference.
https://docs.aspose.com/words/net/mail-merge-and-reporting/

You can overcome this issue (page break delete issue) by changing your template. You can use one of the following approach to overcome this issue.

  1. Insert section break (next page) instead of page break in your template document
  2. Insert an extra paragraph after page break in your template document
  3. Shift the contents of the next paragraph to the previous paragraph i.e move “Test1” to the end of the TableStart line (Please do this with the region after page break)

I have modified your template document for each of above approach. Please find the documents in attachment. Please execute your shared code with each document, you will get the correct output.

Please let us know if you have any more queries.

Hi tahir.manzoorv,
Thank you so much for your reply. It fixed the issue.
But after checking the few scenarios still i have the below issue
Steps to replicate issue use the same code which i sent you previously and same document but with the following data
So my data is as follows

3 4 5
1.First Row
2.Second Row Data
3.Third Row Data
4.Forth Data
5.Fifth Row Data
1/2/2013 1

If you observer the above data, data itself contains the single line space.
My expectation is after the mail merge I should see the data
in the above way only but it is coming as follows
1.
First Row 2.Second Row Data 3.Thrid Row Data
4.Forth Row Data 5.Fifth Row Data

The above is not correct, because what ever data i gave in the same way it should come after mail merge also but it is not happening.
I guess you understand my point. Please let me know how to
fix it.
I tried with the following options
By removing the
doc.MailMerge.CleanupOptions |= Aspose.Words.Reporting.MailMergeCleanupOptions.RemoveEmptyParagraphs;
and adding also I tried but in both cases it is not coming as correctly.
Please let me know how to address the above.
Thanks,
Burepalli V S Rao.v

Hi Burepalli,

Thanks for your inquiry. It would be great if you please share some more detail about your datasource. You can use the shared data with line break as shown below.

table.Rows.Add(“First
Row \n\n2.Second
Row Data 3.\n\nThrid
Row Data 4.\nForth Row Data 5.\nFifth Row Data”, DateTime.Now, 100);

If you still face issue, please create a simple application (for example a Console Application Project) that helps us reproduce the same problem on our end and attach it here for testing. Unfortunately, it is difficult to say what the problem is without the Document(s) and simplified application. We need your Document(s) and simple project to reproduce the problem. As soon as you get these pieces of information to us we’ll start our investigation into your issue.

Hi tahir.manzoorv,
Thanks for your reply. But coming to the data, the above data I am reading it from the Text area in my aspx page if I read that data I am getting in the below way

table.Rows.Add("1.First Row\r\n\r\n \r\n\r\n2.Second Row Data\r\n\r\n \r\n\r\n3.Third Row Data\r\n\r\n4.Forth Data\r\n\r\n \r\n\r\n5.Fifth Row Data\r\n", DateTime.Now, 100);

Can you please check for the above with the same code and same word document you will directly see the issue.
Thanks,
Burepalli V S Rao.v

Hi tahir.manzoorv,
any update for the above.
Thanks,
Burepalli V S Rao.

Hi Burepalli,

Thanks for your inquiry.

I have tested the scenario with following code example and have not found the shared issue while using latest version of Aspose.Words for .NET 13.7.0. I have attached the input and output documents with this post for your kind reference.

If you still face issue, please create a simple application (for example a Console Application Project) that helps us reproduce the same problem on our end and attach it here for testing. Unfortunately, it is difficult to say what the problem is without the Document(s) and simplified application. We need your Document(s) and simple project to reproduce the problem. As soon as you get these pieces of information to us we’ll start our investigation into your issue.

Document doc = new Document(MyDir + "Test10.doc");
var resultantDataSet = new DataSet();
var table = new DataTable { TableName = "2" };
table.Columns.Add("3", typeof(string));
table.Columns.Add("4", typeof(DateTime));
table.Columns.Add("5", typeof(int));
table.Rows.Add("1.First Row\r\n\r\n \r\n\r\n2.Second Row Data\r\n\r\n \r\n\r\n3.Third Row Data\r\n\r\n4.Forth Data\r\n\r\n \r\n\r\n5.Fifth Row Data\r\n", DateTime.Now, 100);
table.Rows.Add("wwwwwwwwwwwww", DateTime.Now, 100);
table.Rows.Add("eeeeeeeeeeeeee", DateTime.Now, 100);
if (table.Rows.Count > 0)
{
    resultantDataSet.Tables.Add(table);
    var dt = new DataTable("1");
    var dr1 = dt.NewRow();
    dt.Rows.Add(dr1);
    resultantDataSet.Tables.Add(dt);
}
var table1 = new DataTable { TableName = "7" };
table1.Columns.Add("abc", typeof(string));
table1.Columns.Add("def", typeof(DateTime));
table1.Columns.Add("ghi", typeof(int));
table1.Rows.Add("wwwwwwwwwwwww", DateTime.Now, 100);
table1.Rows.Add("eeeeeeeeeeeeee", DateTime.Now, 100);
if (table1.Rows.Count > 0)
{
    resultantDataSet.Tables.Add(table1);
    var dt = new DataTable("6");
    var dr1 = dt.NewRow();
    dt.Rows.Add(dr1);
    resultantDataSet.Tables.Add(dt);
}
doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;
doc.MailMerge.ExecuteWithRegions(resultantDataSet);
doc.Save(MyDir + "Out.docx");

Hi tahir.manzoorv,
You are contradicting by yourself. In the previous email trail yourself told me that do not use the
doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;
But now again you added it and you already know with the above we are having other side effects.
And moreover i am using the aspose 13.4.0.0 version.
With the above version & without using the above statement is there any alternative?
please let me know. and i am not interested to post these many times on this issue.
Thanks,
Burepalli V S Rao.v

Hi Burepalli,

Thanks for your inquiry.

sburepalli:
You are contradicting by yourself. In the previous email trail yourself told me that do not use the
doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;
But now again you added it and you already know with the above we are having other side effects.

Please check my reply at following forum link. The solution provided at following forum link solved the page break issue. You can use MailMergeCleanupOptions.RemoveEmptyParagraphs with the solution provided at following forum link.
https://forum.aspose.com/t/52268

*sburepalli:
My expectation is after the mail merge I should see the data in the above way only but it is coming as follows

  1. First Row 2.Second Row Data 3.Thrid Row Data 4.Forth Row Data 5.Fifth Row Data*

I have created and attached a Console application for this issue. The RemoveEmptyParagraphs does not effect this issue. You can test this by removing all Cleanup Options. I have attached the input and output document with this post for your kind reference.

If the problem still remains, please modify the attached Console application according to your requirements and send it back to us along with your input document. I will investigate the issue and provide you more information.

The issues you have found earlier (filed as WORDSNET-1252) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(4)