Fill in Table Data in a DOCX File in JavaScript

1 min readAug 24, 2021

If you have active online Word files, you know that editing and adding new information to them is a constant and tedious task. In this tutorial, we will provide you with an API solution that can be used in JavaScript to easily replace placeholder rows in a DOCX file using one or more templates. If you have other changes to make to the document, those can be made with the same secure editing URL that is returned from this operation.

Our first step is to install the jQuery library:

bower install jquery

After the installation, we can call the function with the following code:

var settings = {
"url": "",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"data": {
"InputFileUrl": "<string>",
"InputFileData": "<byte>",
"TableStartTag": "<string>",
"TableEndTag": "<string>",
"DataToFillIn": "{\"Cells\":[{\"TargetTag\":\"<string>\",\"ReplacementValue\":\"<string>\"},{\"TargetTag\":\"<string>\",\"ReplacementValue\":\"<string>\"}]}",
"DataToFillIn": "{\"Cells\":[{\"TargetTag\":\"<string>\",\"ReplacementValue\":\"<string>\"},{\"TargetTag\":\"<string>\",\"ReplacementValue\":\"<string>\"}]}"
$.ajax(settings).done(function (response) {

With this, you will be able to quickly and safely add table data to your Word documents. Once all changes are complete, you can use the Finish Editing API to close the editing session and download the result.




There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.