Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Mar 08, 2016 7:11 am

I just completed my first MailMerge test with Spire.doc and none of the merge fields that include math worked. For example, here is one of the fields in our template:

!Syntax Error, « (oops, pasting it doesn't seem to work either)
In plain text { = { MERGEFIELD NoteAmount \* MERGEFORMAT } * 1.25 \# $##,###.00 \* CHARFORMAT }

This Word function accepts a merge field called NoteAmount, multiplies it by 1.25 and displays the result in a currency format. This function merges correctly in our current document management system, which uses Word Automation on the client-side. We are looking for a solution that can provide this functionality on the server side.

Any suggestions other doing the calculation prior to performing the MailMerge.Execute function? Our document sets are 45 pages long and contain hundreds of formulas like this. I don't want to lose the ability to edit the template without touching the code.

Thanks

DavidHuey
 
Posts: 8
Joined: Tue Mar 08, 2016 5:28 am

Tue Mar 08, 2016 7:31 am

I found a similar reference in the forum that suggesting using
Code: Select all
document.IsUpdateFields = True
, but when I call SavetoFile with that option set as True, I get the following error:


StartIndex cannot be less than zero.
Parameter name: startIndex
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex

Source Error:



Line 221:
Line 222: Dim strCompletedFileName As String = grdLoans.SelectedDataKey.Value.ToString() & "##" & strTemplateName
Line 223: oDocument.SaveToFile(Request.PhysicalApplicationPath & "CRM\MergeDocs\TempMergeFiles\" & strCompletedFileName & ".docx")
Line 224:
Line 225:

[ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex]
System.String.Remove(Int32 startIndex) +11690962
Spire.Doc.Fields.Field.ᜆ() +673
Spire.Doc.Fields.Field.Spire.Doc.Layout.IDocumentWidget.Measure(spr₶ dc) +9407
sprⁱ.ᜀ(RectangleF A_0) +395
sprᥢ.ᜃ(spr⊐ A_0) +699
sprᥢ.ᜀ(RectangleF A_0) +1215
sprḱ.ᜃ(spr⊐ A_0) +2591
sprᥢ.ᜀ(RectangleF A_0) +1215
sprᥢ.ᜃ(spr⊐ A_0) +699
sprᥢ.ᜀ(RectangleF A_0) +1215
sprᥢ.ᜃ(spr⊐ A_0) +699
sprᥢ.ᜀ(RectangleF A_0) +1215
sprហ.ᜀ(spr᝽ A_0, sprẘ A_1, spr₶ A_2) +757
sprᲦ.᜔() +1085
sprᲦ.ᜀ(Document A_0) +206
Spire.Doc.Document.ᜱ() +111
Spire.Doc.Document.ᝉ() +77
Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat) +298
Spire.Doc.Document.SaveToFile(String fileName) +111
Loan_List.lnkLoans_Docs_Click(Object sender, EventArgs e) in C:\Users\David\Dropbox (SoundEquity)\Sound Equity\Technology\WebSite-v6_Zoho\Loans\LoanList.aspx.vb:223
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +106
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9752530
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3562

DavidHuey
 
Posts: 8
Joined: Tue Mar 08, 2016 5:28 am

Tue Mar 08, 2016 8:18 am

Hello,

Thanks for your feedback. Could you supply a document for our testing? If it is not available, you can send it to my email(gary.zhang@e-iceblue.com).

Thanks in advance,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Mar 08, 2016 4:15 pm

Thanks for the quick reply. Attached is a small sample template that produces the error.

If IsUpdateFields = False, I can save the merged document as a docx and can manually open the document, select all, right click and select Update Fields and I get a correctly merged document.

If IsUpdateFields = True, I can't save the document at all.

Also, I just discovered that saving to a PDF generates the same error whether IsUpdateFields is true or false.

Thanks for your help.

DavidHuey
 
Posts: 8
Joined: Tue Mar 08, 2016 5:28 am

Wed Mar 09, 2016 2:06 am

Hello,

Thanks for the information. I have posted it to our Dev team, once it is resolved or we have some other update for you, we will let you know ASAP.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Mar 24, 2016 7:50 am

Hello,
 
Now the issues have get resolved, and the new hotfix(Spire.Doc Pack(hot fix) Version:5.6.62) has been released, you can download it and have a try.
 
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc