problem:
With ONLYOFFICE Api Documentation - MailMerge example, create an docx to mailmerge works fine.
Doesn’t work this steps:
-
Create a example docx:
builder.CreateFile(“docx”);
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var arrField = [“Greeting line”, “First name”, “Last name”];
for (let i = 0; i < 3; i++) {
var oRun = Api.CreateRun();
oRun.AddText(arrField[i]);
oParagraph.AddElement(oRun);
oRun.WrapInMailMergeField();
oParagraph.AddText(" “);
}
oParagraph.AddText(”!");
builder.SaveFile(“docx”, “org2.docx”);
builder.CloseFile(); -
open the docx, mailmerge:
builder.OpenFile(“org2.docx”);
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var arrField = [“Greeting line”, “First name”, “Last name”];
Api.LoadMailMergeData([arrField, [“Dear”, “John”, “Smith”], [“Hello”, “Lara”, “Davis”]]);
Api.MailMerge(0);
builder.SaveFile(“docx”, “MailMerge.docx”);
builder.CloseFile();
DocumentBuilder version:v7.2.0.204
Installation method: exe installer
OS: windows 11