Replace list of string in Word document Table

Replace list of string in Word document Table

Comments

  • Hi everyone,

    Im currently working on a project where I need to fetch data from an external source and insert it into a Word document in a table format. The Word document has a specific table format that needs to be followed. However, the fetch query can return different numbers of results, including zero results, one result, or more than 60 rows depending on the database tables entries.

    Im looking for advice on how to have a dynamic replace text in the Word document logic that can keep the static text and company logo as is but only replace the tokens of the table with the query results, regardless of the number of results.

    One idea I had was to use a merge HTML table if the query result returns more than one row and somehow place this table on the provided Word doc, which is only one page with a blank table. Im wondering if this is a viable option, and if not, what other methods can be used to achieve the desired outcome.

    FYI, I have 5 columns in total

    Any guidance or suggestions would be greatly appreciated. Thanks in advance!

  • Unknown
    edited November 2023

    Hi,

    Have you tried using the Replace Text in Word Document step? The step takes in a document and can replace specific keywords, either tokens or bookmarks, and give you fields that can be filled in. I would recommend using the Token mode instead of Bookmarks. Tokens are phrases indicated by surrounding the name with a start and end character. By default, the start and end token characters are the curly brackets. If needed, you are able to change the characters used to define the start and end tokens. You can upload the document as file data or have it statically added.

    For instance, in a word document, the phrase {example1} would appear in the step as a field to fill out. You can see it here in the screenshot below.

    I hope this helps!
    ~David G

Sign In or Register to comment.