We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Leading zero dropping for varchar field

Hi Aspose team,

The aspose version in my code is 7.0.0 and we are using word 2007 and 2010 to generate templates.
The problem we are facing is there is a varchar fields which our website has and user enter some data in it. That field don't have any size limit or any specific format (like SSN or ZIP code) to be followed by user.

In such cases if users enters value like '012345678' , template is dropping first i.e. leading zero.

Now the issue is we dont have any format nor the size for this field , so in this case how to use a merge code not to have leading ZERO dropped after document generation?

The same issue we faced for zip code but we used a mergecode for this field as it has specific format lets say 5 digit zip code..after applying merge code for 5 digit zip code issue resolved.
MERGEFIELD ProjectZipCode\#"00000" \* MERGEFORMAT

Thanks for you help.


Thanks for your inquiry.

First off, you are using a very old version of Aspose.Words, and we suggest you please upgrade to latest version 14.5.0 from the following link as it contains newly introduced features, enhancements and fixes to the issues that were reported earlier:

Secondly, please see attached sample input/output documents, in this case, you can simply pass value in string format as follows:

Document doc = new Document(MyDir + @“in.docx”);

doc.MailMerge.Execute(new string[] { "testField" }, new object[] { "000012345678" });

doc.Save(MyDir + @“out.docx”);

Please let us know if we can be of any further assistance.

Best regards,