Free Support Forum -

Mail Merge conditional formatting of a cell/row (background color) using Aspose.Words Cloud SDK for Node.js

I want to shade the cell color depending on the condition.
Here’s my template and sample JSON data saved under test (10.3 KB)
.Conditional formatting is not working and the API documentation is not helping. I want to use if block and want to change the table cell background depending on the condition where the value is 0.


Thanks for your inquiry. Please note you need to use actual IF Field for conditional IF block. Please find attached sample template (10.9 KB). And for conditional formatting, we will appreciate it if you please share an expected document here. We will look into it and will guide you accordingly.

I didnt understand your demoif template. Like how to use if else condition. I have attached the expected output for the above template and JSON data.demo if expected (9.8 KB)


Thanks for sharing expected output document. We are looking into your requirements and will update you soon.


Please note Aspose.Words Cloud does not support to change cell/row background color using Mail Merge/Mustache Template. However, you can format text conditionally as per your requirement. Please find the sample template and output, hopefully it will help you to accomplish the (22.2 KB)

the demoif zip which you ll have provided. Doesn’t contain any solution or syntax of the same. Please provide pproper solution or syntax, which I can implement.


As stated above, you can change the text color using mail merge. It does not support changing cell/row background color conditionally using Mail Merge/Mustache Template. Please elaborate, what do you mean that it doesn’t contain any solution or syntax of the same?

Sir, can you please share the snippets for changing the text color conditionally using Mail Merge/ Mustache Template. I have attached expected output word file.Expected (11.0 KB).


Please find sample Mail Merge Node.js code (10.9 KB). Hopefully it will help you to accomplish the task.

const { WordsApi, PostExecuteTemplateRequest } = require("asposewordscloud");

wordsApi = new WordsApi("xxxxx-xxxx-xxxx-xxxxx-xxxxx", "xxxxxxxxxxxxxxxxxxxxx");
var StorageApi = require("asposestoragecloud");
storageApi = new StorageApi({ appSid: "xxxxxxxx-xxxx-xxxxx-xxxx", apiKey: "xxxxxxxxxxxxxxxxxx", baseURI: "" });
var fs = require('fs');

const templateLocalPath = "demoIf.docx";
const dataLocalPath = "C:/Temp/demoData.json";
const remoteFileName = "ExecuteTemplateIf.docx";

// Upload File
storageApi.PutCreate(templateLocalPath, null, null, templateLocalPath, (responseMessage) => {
console.log("Uploaded File");    
// MailMerge Template
var request = new PostExecuteTemplateRequest(); = templateLocalPath; = fs.readFileSync(dataLocalPath, "utf8");

wordsApi.postExecuteTemplate(request).then((result) => {    
}).catch(function(err) {
    // Deal with an error