Free Support Forum -

Calculate SUM, AVG and SUB in Mail Merge Template using Aspose.Words Cloud SDK for Node.js

I am facing issues with merging field. I am using mail merge template which I have created and passing the JSON data .Here my test folder test (9.7 KB)
I want to calculate sum or other functions by combining values of two fields. I couldnt find any solution anywhere. This is for nodejs.


Thanks for your inquiry. We are looking into your requirement and will update you shortly.

any solution, sir ?


Please find updated template along with the output. I have amended your template, hopefully it will help you to accomplish the (18.6 KB)

Please provide proper syntax or solution, so that i can implement the same.


Please elaborate, what issue are you facing with the above shared template? Sum is working fine in the mailmerge operation.

Sir, can you please share snippets for implementing Arithmetic operation in Aspose word cloud. Such as SUM(), AVG(). For eg. SUM({{value1}},{{value2}}) using Mail Merge/Mustache Template.


Thanks for your feedback. Please find sample code snippet and (9.7 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 = “sumMergeField.docx”;
const dataLocalPath = “C:/Temp/demoData2.json”;
const remoteFileName = “sumMergeField_output.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