Formatted Merge Field Not Displaying Correctly

When merging data into a master document that contains a merge field that has formatting assigned, the formatting is not applied to the data when processed via Aspose.Words. The formatting does work when the merge is done using MS Word.

Is this a known shortcoming of the product or is there a work-around to resolve the issue?
Following are the details regarding how we performed the test:
Word 97-2003 master document contains merge fields as shown below:
(This document, named master.doc, is also attached to this Problem Report)
{MERGEFIELD dtLetterDate \@ "MMMM D, YYYY"}
{MERGEFIELD charLetterDate \@ "MMMM D, YYYY"}
{MERGEFIELD decAmount \# "$,0.00 "}
The data source for the master document is a SQL Server table with the following table definition:
create table sg_junk
(dtLetterDate datetime,
charLetterDate char(10),
decAmount decimal(18,2))
And contains the following data:
dtLetterDate charLetterDate decAmount
----------------------- -------------- ---------
2009-10-15 00:00:00.000 10/15/2009 123.45

When merging using MS Word 2007, the following correct results as displayed:
October 15, 2009
October 15, 2009
But when merged via Aspose.Words, we get the following:
The merge is initiated by calling the MailMerge.Execute method with a c# datatable as its argument.
10/15/2009 12:00:00 AM


Thanks for your inquiry. At the moment Aspose.Words requires picture format switches in fields to be in the US (InvariantCulture) format. This is because Aspose.Words uses standard .NET functions to format values and the standard .NET functions require InvariantCulture format strings.
You should specify format as shown below:
{ MERGEFIELD dtLetterDate \@ "MMMM d, yyyy" }
{ MERGEFIELD charLetterDate \@ "MMMM d, yyyy" }
{ MERGEFIELD decAmount \# "$,0.00" }
I attached my template and output documents. Here are steps I followed:

  1. Create table in the database:
create table sg_junk (dtLetterDate datetime, charLetterDate char(10), decAmount decimal(18,2))
  1. Insert data into the table:
INSERT INTO sg_junk (dtLetterDate, charLetterDate, decAmount) VALUES (GETDATE(), N'10/15/2009', 123.45)
  1. Use the following code to fill the document with data:
string connectionString = "server=myserv;database=TestDB;uid=sa;pwd=mypass;";
string commandString = "SELECT * FROM sg_junk";
DataSet ds = new DataSet();
using(SqlConnection conn = new SqlConnection(connectionString))
using(SqlCommand command = new SqlCommand(commandString, conn))
using(SqlDataAdapter adapter = new SqlDataAdapter(command))
    // Read dataset
// Open template.
Document doc = new Document(@"Test001\in.doc");
// Execute mail merge
// Save output document.

Best regards.