How to fill in preexisting empty table in word .docx from datatable?

I can’t find anything on how to fill in an empty table in a word .docx from a datatable… only how to insert a table (which I have done). Any help would be greatly appreciated. Also, without using the marketplace… Thanks!


Create one word document template and write some unique text into that empty table. And then use Replace Text activity to replace that unique text with required data.

thank you, I thought of doing this however it seems like there should be a better approach… hmmm

Hello @rgvaleno

Is this a default twmplate or will it get change??

If its static what you can do is create bookmarks and use word activities to insert data to that bookmarks. You can refer the below video.

this is a static template… however I have an empty table in a .docx file which is 5 columns and 14 rows… so I’d need to provide 70 bookmarks? Would I be better off with document understanding and converting this to a PDF?

So in the word file do you just want to keep only the table or some other informations also?

If only table maybe you can convert the excel direclty to pdf.

other information also, there’s no excel file… just querying a database, and entering the results into an empty table in a word .docx

@rgvaleno if you query you will be getting the result as datatable, write it to an excel sheet and then convert that to pdf.

@rgvaleno How about doing this. Query the database, the output will be a data table, now write that output in a doc .Ref below lin

Insert DataTable in Word doc

I need to get the datatable into a preexisting blank table in a word document. I can successfully insert the table into the .docx, however I need the header to be white text with a blue background which I can’t seem to figure out without using the marketplace. The simpler way seems to be just filling out the existing blank table… hence my original question. thanks for all the suggestions, maybe I’d be able to do this better with document understanding???

Not sure how this can be achieved with document understanding. Bcoz here you are jut trying to insert data to table in the docx…

And you are not gettinh any specific values from any document and you are getting it directly feom database .

Here you need to finalize a methid for inserting to doc. Either using bookmark & word activities or by using replace method.

HI @rgvaleno ,

Could you explain a bit more as to How is the Table Structure and let us know if there are already some cells which are filled ?

Also, take a look at the below post which might contain a possible solution for your case :

@supermanPunch, thank you for this. I have an empty (except for a header) table in a .docx file which has 5 columns and 14 rows. One of those columns has a dropdown option to be selected. None of the cells are filled except for the header which consist of the column titles. I will be querying a database and pulling information to be entered into this empty table. the number of records will vary, and if >14 I will need to fill in another .docx with the same empty table, and so on. I’m unable to use the marketplace unless it’s an “official” package. The header is currently formatted which gets lost if I were to insert my own table. Also, The table in the .docx file is locked by the vendor so I’m even unable to delete it at this point. I’m looking for an elegant solution as in iterating through the rows of the datatable, and copying said row into the .docx table. The .docx table has 70 fields, so that’s alot of bookmarks/replace text activities. Thankls again

@rgvaleno ,

In that case, can you maybe provide us with sample input data and the Expected Output for that data ?

Here, In your case, you would need to provide the initial .docx file, and the filled in .docx file along with the Table data maybe in the form of Excel.

You wouldn’t need to provide us with the actual data, but the format of the files need to be the same.

This way we could get an idea as to How to actually prepare the logic for this task.

Based on this statement, your case also looks like it can be simply handled using making Bookmarks/Placeholders, as you would be placing/marking the 70 fields bookmarks once, then we wouldn’t need to mark it again, as we can copy the word doc and do the same operation on it again.
Although, we would need to actually take a look at the Table in the word document.