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

Free Support Forum - aspose.com

1. Tables with multiple section and 2. HTML support


I have 2 questions as outlined in the heading. The first question is - Is it possible to populate a table in MS word with sections? In other words, if you have a table (from SQL Server) such as this:

Column1 Column2
1 A
2 A
3 A
6 B
7 B
2 C
4 C
5 C

Is it possible to generate a report in tabular format in MS word that looks like this




My second question was derived from trying to find a solution to the above problem. When I saw that you supported insertHTML in the DocumentBuilder I thought all my problems have been answered. The problem was you don’t fully support Tables and CSS. To create the report using your example of creating a chess board can work but the problem is that the table that I am creating is very complicated. When are you going to fully support HTML.


What you describe here is what we call the “nested merge region” problem. What’s required is a feature to be able to include parent-child data relationships in the report. Think of Order-OrderItem or ProductCategory-Product in your case. If Column2 was ProductCategory then Column1 is Product.

Nested regions are not supported yet, but we plan to implement this feature and it will be the easy way to create this reports. In the meantime we need to workaround and I’m long overdue on creating a sample to show how to do that.

From what I can see you are actively thinking about the problem so will just give pointers that should help you succeed quicker than I can create the demo.

1. You need two template documents. One will be the “main” document and the other will contain just the table (products in one category). You will populate the document with products as many times as there are categories and append the resulting document to the main document.

2. In the table document, create the header of the table and one row. Use MS Word for this to visually design your complex table. Then mark the row in the table as a merge region and insert merge fields into the row, similar to the Invoice example in the demo project.

3. Open the table document in Aspose.Word, select all rows in the data source for ProductCategory “A”, and then MailMerge.ExecuteWithRegions to populate the table.

4. Move the section from the table document to the end of the main document. Use Sections and Section for this.

5. Repeat from p.3, but select all rows in the data source for the next product category. You can speed the thing up if you don’t open the table document every time, but clone it in memory.

Let me know if that makes sense.

I would stay away from trying to involve HTML in this “simple” case of populating a report with data.

Full support for CSS is not going to be available very soon because CSS seems quite complex. It will be several months away.

It makes perfect sense. I need to go through the documentation about merging two templates. I will keep you posted on my progress. We seem to have time lag problems because I am calling from South Africa.

Another thing, When developing the nested merge regions, can you think about mapping the merged fields within the regions to code similar to a bound Datagrid or DataList in ASP.NET.


Not sure what do you mean by mapping of merge fields.

I’ve decided to create a demo that creates a Product Catalog with categories very similar to the scenario we are discussing here. Hopefully it will be ready within the next few days.

Thanks, I am sure that I will find the demo very useful. My deadline is Monday to present to the board so that they can buy a licence.

Mapping merge fields:
In ASP.NET, when binding a datalist you can use the following syntax <%# function(<parameters&gtWink %> within the datalist. If you could have this feature it would help developers build dynamic reports in MS word similar to ASP.NET.


How is the demo coming along? Cool


I’m doing a slightly bigger update of existing demos, I think it will be ready by Monday.

I managed to figure it out using your guidelines. Now, I want to insert the main report (table) into another document inside a Table. Is there a way I can isert a table/section into a table in a different document?


Document manipulation is not easy at the moment. You can only move whole section between documents and it can be inserted in between other sections only, cannot go into a table.

Aspose.Word 2.1.3 is released with new demos, for more info see https://docs.aspose.com/words/net/working-with-tables/

The issues you have found earlier (filed as 39) have been fixed in this update.

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