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

Free Support Forum - aspose.com

Single Table Cell

If I mark up one cell (one column) in a Word table with a TableStart TableEnd region, and merge a datatable to it, it places all the rows from the datatable into one cell, instead of adding additional table rows. When working on two columns, Aspose automatically adds rows. My merge field looks like this inside the one cell:

«tablestart:new two»«FullFormName»«tableend:new two»

How can I make a single column table add rows, and not place all the data inside one cell?

Hi

Thanks for your request. You should insert TableEnd at the end of cell.

«tablestart:new two»«FullFormName»

«tableend:new two»

I hope that it will help you.

Best regards.

When I do that I get the error:

Mail merge region 'new two' is badly formed. Tablestart and Tableend should be in the same section, same table row or same table cell.

What do I do?

Hi

Try to use the attached template.

Best regards.

It says Attachment: inaccessible.

Hi

Can you give me your e-mail? I will send the file to you.

Best regards.

derekmhart@yahoo.com

I have sent the document by E-Mail.

Best regards.

This is giving me the exact same error. Is it possible this was fixed since the version I am on, which is 4.2.5.0 ?

Hi

Thanks for additional information. Please, try to use the latest version of Aspose.Words. You can get the latest version here:
http://www.aspose.com/Community/Files/51/aspose.words/entry91746.aspx

Best regards.

OK, I upgraded to version 4.4 - still getting the same error with your exact word doc.

Mail merge region 'table' is badly formed. Tablestart and Tableend should be in the same section, same table row or same table cell.

Please let me know how to proceed.

Derek

Also, note that your documentation has the following statement under

MailMerge.ExecuteWithRegions Method (DataSet)

If used inside a table, TableStart and TableEnd must be inside the same row in the table.

Hi

I have used the following code and it works fine on my side.

Document doc = new Document(@"247_97654_derekmhart@yahoo.com\in.doc");

DataTable table1 = new DataTable("table");

table1.Columns.Add("field1", typeof(string));

DataRow dr = table1.NewRow();

dr[0] = "test";

table1.Rows.Add(dr);

DataRow dr1 = table1.NewRow();

dr1[0] = "test";

table1.Rows.Add(dr1);

DataRow dr2 = table1.NewRow();

dr2[0] = "test";

table1.Rows.Add(dr2);

doc.MailMerge.Execute(table1);

doc.Save(@"247_97654_derekmhart@yahoo.com\out.doc");

Best regards.

OK, I see something different here. I am using ExecuteWithRegions, not Execute, to fill in a Word table. You will get the error. Please try.

Hi

I have found some workaround for you. See the following code and the following template

Document doc = new Document(@"in.doc");

DataTable table1 = new DataTable("table");

table1.Columns.Add("EmptyField", typeof(string));

table1.Columns.Add("field1", typeof(string));

DataRow dr = table1.NewRow();

dr[0] = "";

dr[1] = "test";

table1.Rows.Add(dr);

DataRow dr1 = table1.NewRow();

dr1[0] = "";

dr1[1] = "test";

table1.Rows.Add(dr1);

DataRow dr2 = table1.NewRow();

dr2[0] = "";

dr2[1] = "test";

table1.Rows.Add(dr2);

doc.MailMerge.RemoveEmptyParagraphs = true;

doc.MailMerge.ExecuteWithRegions(table1);

doc.Save(@"out.doc");

Create the template like the following.

«TableStart:table»«EmptyField»

«field1»

«EmptyField»«TableEnd:table»

Best regards.

Hi.

I’m facing the exact same problem during the delivery of a proof-of-concept project from which depends
the purchase - or not - of the Aspose.PDF and Aspose.Words packages.

The problem is that the workaround works fine when the list is indeed a table with a single cell, but when the table has a header, this just doesn’t work.

See the attached file to see what I mean.

How should we proceed with this issue?

Best regards,

Paulo Tavares

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think you can split your table to two tables. One will contain header of table, other it’s content. See attached template. And here is code:

DataTable table = new DataTable("HAN_FinancialList_All");

table.Columns.Add("HAN_Finance_IOL_All");

table.Columns.Add("emptyField");

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

{

table.Rows.Add(new object[] { string.Format("item_{0}", i), string.Empty });

}

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

doc.MailMerge.RemoveEmptyParagraphs = true;

doc.MailMerge.ExecuteWithRegions(table);

doc.Save(@"Test176\out.doc");

Best regards,