How to add tables to Word templates

By Kristina posted 01-28-2015 22:21

If you’d like to display your items in a table, you can make use of the CHILDREN mail merge codes to do so. It is important to note that you cannot mix item types in the output, however. The item type that you indicate as a child will be the only type to return. 

Here is an example table using mail merge fields.

If you take a  simple hierarchy of requirements 

and create such a template, it will produce an output like this:

As you can see, each folder will be displayed along with a table of all items of type Requirement that exist exactly one level below the specified folder. Further-removed descendants of the folder (grandchildren, etc) will not be shown. Unfortunately, it is not possible to nest CHILDREN tags, so there is no way to view the full descendent hierarchy of an item via this method.
Remember, only one specified item type will show in each table. While our output shows the “Interfaces” folder, that folder does not have any direct children of the Requirement type, so the contents of that table are blank. If you’d like to show other child item types, it is possible to insert those into a separate table in the same item type template.

You can download a copy of this template via Box:

#OfficeTemplates #tutorial


06-19-2015 16:01

Thanks all... I think we're getting closer with the use of a VBA macro.  We may need to put some time into learning a bit more Velocity... seems like it can be quite powerful.


06-19-2015 15:56

Unfortunately, the select all, cut, & paste does not work either.

06-18-2015 20:36

I cannot even spell her name correctly. @Shawnna. :-) this is why I can never code a Velocity template. :-)

06-18-2015 20:30

We all want to be like Shawnna!

06-18-2015 16:43

@Kristina, thanks for double checking. Perhaps you can contact Mike and his company privately regarding the feasbility and the cost of using Velocity to generate t he desired output. I gave up on learning Velocity when I realize that there is no graphical development and debug vehicle and have to code Velocity template control code, HTLM tags, Jama data/API calls... :-) When I grow up, I want to be like @Shawna :-)

06-18-2015 16:11

Hi Mike,

I checked with the rest of the Support team and our consultants, and at this point we don't have any suggestions to get exactly what you want out of the templates. I think Swoo's suggestions are comprehensive. I'll be sure to update this post if anyone thinks of something, though.

06-18-2015 11:10

Mike, I was afraid that the macro that I got off the internet may have been too "aggressive." Do try to open your original, post-processed file in Word, do a select all, cut, and paste. In the past somehow the tables magically healed themselves...It may not work for your version of Word, but give it a try anyway...Good luck.

06-18-2015 02:39

Thanks Swoo,

This macro definitely collapses all the tables together... even ones that weren't intended to be collapsed!  Interestingly, it also removes all the Word Heading text between the tables.  So all the structure that is needed for the document (such as the Heading " Wake on functions" shown in my screen shot above) is also eliminated. 

This macro could work on a very simple document, but if the structure is also needed (which is the reason we have the <<TemplateStart:FLD>> and <<TemplateStart:HEADING>> sections in the template) then macro will instead need to work on each 'chapter' of the document at a time, which is very slow on a document with ~3000 or more paragraphs. 


06-17-2015 22:51

Mike, understand your point. Have you tried the macro to merge your tables yet? By the way, the usual Jama consultants may advise you to try Velocity. There are actually a couple of Velocity experts and even a Jama report developer on the forum. Good luck. I will learn Velocity in two years after I learn simple Birt stuff in the next two years. Swoo

06-17-2015 22:47

Thanks Swoo,

An interesting approach, but unfortunately we will not have control over the filter the user has created.  To take this approach, we would (in effect) need to build the filtering capability into the Word document macro (along with a user interface) and export all fields which the user might want to filter on (and also tell the user that the filter will need to be built in both Jama and the Word document... the first to see what will be added to the document and the second for the actual export).  For very simple stuff, the approach might work, but we would need a better solution for our customer.


06-17-2015 13:30

Hi Mike,

For your first method, I remembered another work-around I had in case your filter is very simple. What I used to do is to export everything out and then write a Word VBA macro to remove. For example, if I have items that have a field marked "delete_me" then my VBA macro will remove those items/rows in the output Word. This is a very ugly work-around of course. Good luck. This is because the current version of Jama export engine seems to find the folder and then export all its children regardless of the actual filtered results.


06-17-2015 10:12


For your second case: for merging separate tables I use to just select all, cut, and paste in Word interactively. Do not know why it worked and whether it will work in your case.

I just Googled and found. You might give this a try. Hopefully you end up with the desired result. I have not tried the following. Good luck.


Dim rng As Range

Dim i As Long

With ActiveDocument

For i = .Tables.Count To 2 Step -1

Set rng = .Tables(i).Range

rng.Collapse wdCollapseStart

rng.Start = .Tables(i - 1).Range.End


Next i

End With

-- Hope this helps.

Doug Robbins - Word MVP,


Posted via the Community Bridge

"Blackcatwin" wrote in message news:f06acf8c-ffc8-4efa-8431-86c5b6ad8a1f@......

06-17-2015 04:37

This topic seems related, so I'll post my question here.  Please split off if necessary.

We are doing different tables for different types, similar to the following:

This gives the desired result... for those folders which contain the CPBT type, the first table format is used; for those folders which contain the PI type, the 2nd table format is used.  A macro is used to add table headers afterwards.

The trouble is when the user has a filter applied to the List View... despite filtering out certain records, they are still exported to the Word document!  Exporting to Excel yields the expected results, but the output needs to be Word.

The only working alternative we have is to change the word template so that the CPBT and the PI item types are stand-alone Template groups rather than being rolled into the FLD Template group, as shown below:

Now the filter results are honored and we can get unique tables per item type, but rather than having joined tables as shown above, each record has its own table, with a space between (Argh!):

Even removing the space between afterwards with a macro does not necessarily join the separate tables into one. 

Any ideas on how to get the best of both?  A template which honors the filter results AND keeps the records together in a single table?  I've tried several other template combinations, but so far the results have been binary... either the filter is honored or the results are joined into one table... I'm hoping it's just a combination that I haven't been able to figure out yet.


05-06-2015 03:39

Ok, thanks a lot

05-05-2015 14:15

There isn't a way to add any conditions in the Word templates, so I can't think of a way to achieve what you need. You would have to maintain separate templates for different item types. We're exploring updates to our reporting capabilities, so hopefully we work out a way to accommodate this.

05-05-2015 11:02

This is nice to have but It would be even better if we could use this associated with a particular item type. Is it possible?

If I'm exporting multiple sets with different items types and potentially folders in each set, it is likely that I would like different tables for each different type.

Example: I may like/need table for parametric types, whereas no table and just name and description for descriptive types

04-15-2015 16:30

I haven't found a way to do that within the Word template itself.

04-15-2015 14:49

It seems like you can't structure this so that the "Interfaces" folder has no table at all?