Hello,
I have a document with mergefields and cardtext or dollartext but the fields are not displaying the numbers as text.
The formula field the cardtext or dollartext format works fine.
I load the document with Aspose and call UpdateFields() and then save it back as docx.
Can you please help me with this issue?
Here is my test document: Dollartext issue.docx (23.0 KB)
@cternek Merge field in your sample document is used not quite correctly. Mergefield are filled with data upon executing mail merge. So they should look like this:
{ MERGEFIELD test \* CARDTEXT }
{ MERGEFIELD test \* DOLLARTEXT }
Where test
is merge field name. Then in the code, mail merge is executed to fill the document with data:
Document doc = new Document(@"C:\Temp\in.docx");
doc.MailMerge.Execute(new string[] { "test" }, new object[] { 5678.99 });
doc.Save(@"C:\Temp\out.docx");
in.docx (14.3 KB)
out.docx (9.9 KB)
Please see our documentation to learn more about mail merge feature:
https://docs.aspose.com/words/net/mail-merge-and-reporting/
OK, I understand.
In your case the MERGEFIELDS are removed.
In my case I want to keep the MERGEFIELDS after the MailMerge.
Then it is not intended to update those MERGEFIELDS with UpdateFields in the merged document?
Microsoft Words updates those MERGEFIELDS if you click on Update Field.
@cternek It is not supposed to keep MERGEFIELDS after executing mail merge, there are replaced with the data. If you need to preserve placeholders after filling document with data, you can consider using another type of fields. For example you can use DocVariable or DocProperty field and put your data into variables or custom document properties.