open id 

HomeFlows

Replace list of string in Word document Table Messages in this topic - RSS

nimishK
nimishK
Posts: 2


3/18/2023
nimishK
nimishK
Posts: 2
Hi everyone,

I'm 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 table's entries.

I'm 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. I'm 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!
0 link
david.gillespie@decisions.com
david.gillespie@decisions.com
Administrator
Posts: 5


3/20/2023
david.gillespie@decisions.com
david.gillespie@decisions.com
Administrator
Posts: 5
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
0 link
Proffelf
Proffelf
Posts: 2


5/9/2023
Proffelf
Proffelf
Posts: 2
Hello,

One possible approach is to use a library like python-docx to programmatically manipulate the Word document.
You could write a script to fetch data from the external source, format it as a table, and insert it into the Word document based on certain placeholders.
myherbalife
Best regard,
edited by Proffelf on 5/10/2023
0 link






Powered by Jitbit Forum 8.3.8.0 © 2006-2013 Jitbit Software