Free Support Forum - aspose.com

Fomating for mergefields not orking properly

Hi,

I ahve a case where a merge field is playes with formating.
I mean, his is the case

So, when the mergefield gives multiple lines, it should look like
  • test1
  • test2
  • test3
So, it is ok. But when the returning value for the merge field is also with a format i mean here test3 is being coming as test3.
Then what i am geeting is
  • test1
  • test2
test3.

So the preformat is not being applied, if we do have some formating in the mergefield. What should i do?.

Thanks,
Ravi

Hi

Thanks for your inquiry. I think that you should do this using regions. For example see attached template and the following code.

//Create datasourse

DataTable table = new DataTable("table");

table.Columns.Add("field1");

for (int rowIndex = 0; rowIndex < 10; rowIndex++)

{

DataRow row = table.NewRow();

row[0] = "test";

table.Rows.Add(row);

}

//Open template

Document doc = new Document(@"457_109237_raviteja\in.doc");

//Execute mail merge

doc.MailMerge.ExecuteWithRegions(table);

//Save document

doc.Save(@"457_109237_raviteja\out.doc");

I hope that this will help you.

Best regards.