Hi,
I’m getting an InvalidOperationException
on MailMerge.Execute()
:
My template look like this :
{ = SUM({MERGEFIELD dtrecepsi \@ "yyyyy"},1) }
If my datasource has dtrecepsi null, InvalidOperationException is thrown.
I tried as workaround to add a IF field like this :
{ IF {MERGEFIELD dtrecepsi } = "" "" "{ = SUM({MERGEFIELD dtrecepsi \@ "yyyyy"},1) }" }
But the same error is thrown.
What is the best way to do that ?
Could Aspose.Word just ignore empty value in sum fields ?
{ = SUM(,1) } => { = SUM(0,1) }
And I don’t understand why the error is thrown on MailMerge.execute()
instead of UpdateFields
. Did I miss something ?
Thanks for your help
(template and dataset are attached)
code :
Aspose.Words.License Lica = new Aspose.Words.License();
Lica.SetLicense(@\\fidji\Travail\venayre-m\N03\Aspose.Total.lic);
Document doc_out = new Document(Path.Combine(path,"template.doc"));
DataSet ds = new DataSet();
ds.ReadXml(Path.Combine(path, "dataset.xml"),XmlReadMode.ReadSchema);
doc_out.MailMerge.Execute(ds.Tables[0]);
doc_out.UpdateFields();