I am upgrading the Aspose.word dll for .net from 6.2 to 10.4.0.0 and came across an issue with formatting of numbers there is a number with scientific notation 1.2223333E9 which in version 6.2 shows up as 1222333300 on the merged word document. but using the 10.4.0.0 version of the dll the number is displayed as 1.2223333E9
The data is coming from datarow.
Is this a known issue or is there a workaround for this issue.
Thanks
Jinoj Thomas
Hi
Thanks for your request. Could you please attach your document and code that will allow us to reproduce the problem? We will check the issue and provide you more information.
Best regards,
I have attached the word MERGE template Here is the code
step 1 .I get the word template
step 2. populate the DataSet with datatables and datarow
public static DataRow AddSObjectToTable(DataTable thisTable, sObject obj)
{
DataRow thisRow = thisTable.NewRow();
if (obj.Any == null) return null;
for (int j = 0; j < obj.Any.Length; j++)
{
XmlElement currEl = obj.Any[j];
AddFieldValue(thisTable, currEl, thisRow);
}
thisTable.Rows.Add(thisRow);
return thisRow;
}
private static void AddFieldValue(DataTable table, XmlElement element, DataRow row)
{
//double _num;
if (!table.Columns.Contains(element.LocalName))
{
table.Columns.Add(CreateDataColumn(element.LocalName));
}
row[element.LocalName] = element.InnerText;
}
private static DataColumn CreateDataColumn(string fieldName)
{
DataColumn dc = new System.Data.DataColumn(fieldName);
return dc;
}
Step 3 Do the mailMerge
Aspose.Words.Document doc = null;
DataRow dr_FIE = GetIncomeExpense(mergeData.Tables["FIE__X__"]);
int counter = 0;
Aspose.Words.Document docMain = templates[0].Clone();
//Test get the merge field names
string[] mergeFieldNames = docMain.MailMerge.GetFieldNames();
docMain.MailMerge.RemoveEmptyParagraphs = true;
//Merge Statement of Income and special allocations
–Here the number is in 1.3333333333E9…
*****Total Income : 1.0743799E7 , String
System.Diagnostics.Debug.Print(" Total Income : {0} ,,, {1}", dr_FIE["FIE__X__Total_Income__c"].ToString(),dr_FIE["FIE__X__Total_Income__c"].GetType().Name);
docMain.MailMerge.Execute(dr_FIE);
string path = AppConfiguration.GetConfig("SFDC_TemplatesPath");
string gdflpSignature = path + @"\images\GDFLP\db2.gif";
//Merge Signature
docMain.MailMerge.Execute(new string[] { "GDFLPSignature" },
new string[] { gdflpSignature
});
docMain.MailMerge.DeleteFields();
//add to combined pdf
AddToConsolidated(ref ConsolidatedDoc, ref hasConsolidated, docMain);
//add cover letter to docMain
if (docCover != null)
{
doc = AddCoverLetter(docCover, ref PostalCoverDoc, ref hasPostalCover, recip, coverLetterData, docMain);
}
else
{
doc = docMain;
}
doc.CustomDocumentProperties.Add("Identifier", recip.Investment_Account__c);
doc.CustomDocumentProperties.Add("FileName", GenerateFileName(mJob, recip));
docs.Add(doc);
uniqueDocs.Add(GenerateFileName(mJob, recip));
}//end if (!uniqueDocs.Contains(GenerateFileName(mJob, recip)))
Here is a working example where the numbers are formatted incorrectly…
please look at the Total Income (Loss) and Net Income (Loss) for the Period fields
attached is word template out put data and code…
using System;
using System.IO;
using System.Reflection;
using Aspose.Words;
using Aspose.Words.Fields;
using Aspose.Words.Reporting;
using System.Data;
namespace MailMergeFormFields
{
///
/// This sample shows how to insert check boxes and text input form fields during mail merge into a document.
///
class Program
{
///
/// The main entry point for the application.
///
public static void Main(string[] args)
{
Program program = new Program();
program.Execute();
}
private void Execute()
{
string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar;
string dataDir = new Uri(new Uri(exeDir), @"../../Data/").LocalPath;
DataTable table = new DataTable();
table.Columns.Add("FIE__X__Id");
table.Columns.Add("FIE__X__Advisory_Fees__c");
table.Columns.Add("FIE__X__Brokerage_Expenses__c");
table.Columns.Add("FIE__X__Incentive_Fees__c");
table.Columns.Add("FIE__X__Operating_Expenses__c");
table.Columns.Add("FIE__X__Professional_Fees_And_Other__c");
table.Columns.Add("FIE__X__Net_Realized_Gain_Loss__c");
table.Columns.Add("FIE__X__Net_Change_In_Unrealized_Gain_Loss__c");
table.Columns.Add("FIE__X__Net_Interest_Dividend_Income_Expense__c");
table.Columns.Add("FIE__X__Total_Income__c");
table.Columns.Add("FIE__X__Net_Income__c");
table.Columns.Add("FIE__X__Net_Income_After_GP_Fees__c");
table.Columns.Add("FIE__X__Special_Allocation_To_Gp__c");
table.Columns.Add("FIE__X__Net_Income_Pro_Rata_Allocation__c");
table.Columns.Add("FIE__X__Total_Expense__c");
table.Columns.Add("FIE__EXPENSE_NAME_1");
table.Columns.Add("FIE__EXPENSE_VALUE_1");
table.Columns.Add("FIE__EXPENSE_NAME_2");
table.Columns.Add("FIE__EXPENSE_VALUE_2");
table.Columns.Add("FIE__EXPENSE_NAME_3");
table.Columns.Add("FIE__EXPENSE_VALUE_3");
DataRow dr = table.NewRow();
dr["FIE__X__Id"] = "a0570000003OpnhAAC";
dr["FIE__X__Advisory_Fees__c"] = "602972.0";
dr["FIE__X__Brokerage_Expenses__c"] = "784.0";
dr["FIE__X__Incentive_Fees__c"] = "";
dr["FIE__X__Operating_Expenses__c"] = "";
dr["FIE__X__Professional_Fees_And_Other__c"] = "42227.64";
dr["FIE__X__Net_Realized_Gain_Loss__c"] = "8277183.0";
dr["FIE__X__Net_Change_In_Unrealized_Gain_Loss__c"] = "2523722.0";
dr["FIE__X__Net_Interest_Dividend_Income_Expense__c"] = "-57106.0";
dr["FIE__X__Total_Income__c"] = "1.0743799E7";
dr["FIE__X__Net_Income__c"] = "1.009781536E7";
dr["FIE__X__Net_Income_After_GP_Fees__c"] = "5317937.77";
dr["FIE__X__Special_Allocation_To_Gp__c"] = "4779877.59";
dr["FIE__X__Net_Income_Pro_Rata_Allocation__c"] = "";
dr["FIE__X__Total_Expense__c"] = "645983.64";
dr["FIE__EXPENSE_NAME_1"] = "Advisory Fees";
dr["FIE__EXPENSE_VALUE_1"] = "602972";
dr["FIE__EXPENSE_NAME_2"] = "Professional Fees and Other";
dr["FIE__EXPENSE_VALUE_2"] = "42227.64";
dr["FIE__EXPENSE_NAME_3"] = "Brokerage Expenses";
dr["FIE__EXPENSE_VALUE_3"] = "784";
table.Rows.Add(dr);
// Load the template document.
Document doc = new Document(dataDir + "10_10_Template.doc");
doc.MailMerge.Execute(dr);
doc.Save(dataDir + "Out.doc");
}
}
}
Hi
Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. We will let you know once it is resolved.
As a temporary solution, you can pass these numbers as double instead of string. Please see the following code:
DataTable table = new DataTable();
table.Columns.Add("FIE__X__Total_Income__c");
table.Columns.Add("FIE__X__Net_Income__c");
DataRow dr = table.NewRow();
dr["FIE__X__Total_Income__c"] = 1.0743799E7;
dr["FIE__X__Net_Income__c"] = 1.009781536E7;
table.Rows.Add(dr);
// Load the template document.
Document doc = new Document(@"Test001\in.doc");
doc.MailMerge.Execute(dr);
doc.Save(@"Test001\out.doc");
Best regards,
Is there a estimated time when this issue will be resolved because in the earlier version
Aspose.Word.dll 6.2 the scientific notation numbers are formatted correctly
Thanks
Jinoj Thomas
Hi
Thanks for your request. Unfortunately, at the moment I cannot provide you any estimate regarding these issues. Our development team will analyze the issues and then we will provide you an estimate. I apologize for inconvenience.
Best regards,
Thanks Alexey,
I asked for an ETA for this bug because this is the only show stopper for me to upgrade
to the latest version of aspose. Interestingly this problem is handled correctly in version 6.2 of
Aspose.Words.dll. Even an ballpark time to resolve this issue will be appreciated so I can plan accordingly.
Thank you
Jinoj Thomas
Hi
Thanks for your request and sorry for inconvenience. Currently the issue is in the queue for analysis. I asked our developers to provide an analysis of this issue shortly. I will let you know once they finish analysis of the issue.
Best regards,
Thanks
Jinoj
Hello Alexey,
Is the issue with number formatting in the aspose.word.dll resolved. Please provide me an estimate if and when this issue will be resolved because we are planning to upgrade to the new version ASAP and this issue is the only show stopper
Thanks
Jinoj
Hi
Thanks for your request. Unfortunately, there is still no news regarding this issue. We will keep you informed and immediately let you know once the issue is fixed. I apologize for inconvenience.
Best regards,
The issues you have found earlier (filed as WORDSNET-5321) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.