DriveWorks Pro 15: Drive Arrays Into Tables in Word Document [send feedback...]

Drive Arrays Into Tables in Word Document

Data arrays can be driven into tables in Microsoft Word documents.

When a bookmark exists in a cell of a table (in Word), and the rule applied to the captured bookmark results in a data array, DriveWorks will drive each cell in the table to the corresponding value in the array.

If a bookmark is outside of a table, but has an array value applied, then this bookmark will be not be driven.

If a bookmark is within a table, but does not have an array value applied, then this value will be driven as normal into one cell.

Behaviour

Bookmarks in table cells will be driven slightly differently, depending on whether the bookmark is in a single cell, or if it spans multiple cells.

Single Cell Bookmark

If a bookmark is placed in a single cell then DriveWorks will:

  1. Drive from that cell until the end of the table.
  2. DriveWorks will only drive from the column/row the bookmark is in, onwards.
  3. DriveWorks will never add columns. If there are more columns in the array than in the table, DriveWorks will not drive the surplus array values into the table.
  4. DriveWorks will add rows. When the array data has more row values than the table has, rows will be appended to the table.
  5. Any existing data, in the driven cells, will be overwritten.

Multiple Cell Bookmark

Bookmarks that span multiple cells can be created in Word. If this is the case then we will:

  1. Drive from the cell that the bookmark starts in, until the cell it ends in.
  2. Drive from the column/row that the bookmark starts in, until the column/row the bookmark ends in.
  3. DriveWorks will never add columns. If there are more columns in the array than in the table, DriveWorks will not drive the surplus array values into the table.
  4. DriveWorks will insert rows. When the array data has more row values than the bookmark spans in the table, rows will be inserted after the row that the bookmark ends in.
  5. This means any rows below the bookmark end point will maintain any previous data.
  6. Any existing data, in driven cells, will be overwritten.

Preserving Formatting

To preserve any formatting applied to a table it is important to understand the Document Generation Types that DriveWorks uses.

There are two methods of driving Word documents:

  1. Through the Microsoft Word application (.doc files).

    This also applies to:

    • Previewing
    • Creating HTML File
    • Creating PDF File
  2. Using OpenXML (.docx and .docm files).

Table formatting is preserved when documents are generated using the OpenXML method only.

Macro enabled documents (.docm files) are driven using OpenXML and then opened in the application to run the macro. This is to maintain as much table cell formatting as possible.

The legacy .doc file format contains very little formatting information. This means that if there is more data in the array than there are rows in the table, those rows may not maintain the formatting that is expected. For example, adding rows into a table that has alternating row colors will cause a new row to be added with the same row color as the previous one.

Previewing a .docx file, which uses the same document generation type as a .doc file, maintains alternate row colors. This is due to the .docx file format containing the required formatting information.

To have the best chance of preserving formatting it is recommended to either use a .docx or .docm file, or make sure there are enough rows for your data in the table in Word.

Overlapping Bookmarks

Overlapping bookmarks can be created in Word documents. Although they will still be driven, it is not a supported scenario in DriveWorks and therefore the result may differ between the two document generation types.

An entry into the specification report will be added if an overlapping bookmark is encountered when generating the document through the Word application.

The scenario can arise where an overlapping bookmark is being found but there are no visibly overlapping bookmarks in the document. This is a known issue with Word documents reporting intersecting bookmarks incorrectly.

If this is the case, the entry in the report will detail the bookmarks that overlap. The recommended solution is to ensure that just the text that is to be replaced has been highlighted when creating the bookmark and not the whole line.


Table of Contents