We are using Aspose.Words Version=19.12.0.0 for merging data in Word and PDF. I’m updating document field format for ‘NumericFormat’ field with combination of English and Arabic Number formats Like “ArabicSymbol#,##0.00;(ArabicSymbol#,##0.00)”, Once document Merged, Number format has been changes. I mean number format alignment changed in merged word document.
From our side we tried below solution but it’s not working for us. Also we tried others solutions as well as. Maybe we are doing wrong or not sure. So, Can you please guide me if I’m going to wrong way or missed anything?
https://forum.aspose.com/t/problem-with-rtl-ltr-mixed-report/53489
Here is code which I implemented.
Document document = new Document("C:\\Data\\test.docx");
var fields1 = document.Range.Fields;
foreach (Aspose.Words.Fields.Field field in fields1)
{
if (field.Type == Aspose.Words.Fields.FieldType.FieldMergeField)
{
if (field.Format.NumericFormat != null)
{
string FormatString = "$#,##0.00;($#,##0.00)";
FormatString = FormatString.Replace("$", ((Char)0x200F).ToString() + "د.ك" + ((Char)0x200E).ToString());
document.Styles[StyleIdentifier.Toc1].Font.NameBi = "Andalus";
document.Styles[StyleIdentifier.Toc1].Font.SizeBi = 40;
document.Styles[StyleIdentifier.Toc1].Font.Bidi = true;
field.Format.NumericFormat = FormatString;
field.Update();
}
}
}
document.Save("C:\\Data\\Test-Output.docx");
//Set merge cleanup options
document.MailMerge.CleanupOptions = Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveContainingFields |
Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveEmptyParagraphs |
Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveUnusedFields |
Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveUnusedRegions;
document.MailMerge.Execute(new string[] { "Date", "DateTime", "Time12Hour", "Time24Hour", "Revenue", "HidePriceOn", "UnitPrice" },
new object[] { "2018-09-25", "2018-09-25 23:30", "7:00 PM", "19:00", 11.34, "True", 12.234 });
document.Save("C:\\Data\\Test-Merge.docx");
Here is output image file:
Here is Word Document which I am trying to merge data.
test.docx (13.3 KB)