Aspose升级 - 缺少属性

时间:2017-04-18 23:19:35

标签: vb.net upgrade aspose aspose.words

我们正在尝试升级Aspose,并发现较新版本中缺少Aspose.Words.Document.MailMerge。 MergeField MergeFieldEventArgs

有人可以帮我替换这个属性/方法吗?

Dim doc As Document = New Aspose.Words.Document(fileName)
AddHandler doc.MailMerge.MergeField, AddressOf HandleMergeField


Public Sub HandleMergeField(ByVal sender As Object, ByVal e As MergeFieldEventArgs)
    'Do something
End Sub

enter image description here

1 个答案:

答案 0 :(得分:1)

Aspose.Words.MailMerging 命名空间包含邮件合并报告引擎类。请从您的应用程序中删除旧邮件合并命名空间,并添加Aspose.Words.MailMerging命名空间。您需要实现IFieldMergingCallback接口以实现您的要求。请检查以下代码示例。

Public Sub MailMergeInsertHtml()
    Dim doc As New Document(MyDir & "MailMerge.doc")

    ' Add a handler for the MergeField event.
    doc.MailMerge.FieldMergingCallback = New HandleMergeField()


    ' Execute mail merge.
    doc.MailMerge.Execute(New String() { "fieldname" }, New String() { "field value" })

    ' Save resulting document with a new name.
    doc.Save(MyDir & "MailMergeOut.doc")
End Sub

Private Class HandleMergeField
    Implements IFieldMergingCallback
    ''' <summary>
    ''' This is called when merge field is actually merged with data in the document.
    ''' </summary>
    Private Sub IFieldMergingCallback_FieldMerging(ByVal e As FieldMergingArgs) Implements IFieldMergingCallback.FieldMerging
         '' Your code
    End Sub

    Private Sub ImageFieldMerging(ByVal e As ImageFieldMergingArgs) Implements IFieldMergingCallback.ImageFieldMerging
        ' Do nothing.
    End Sub
End Class

我与Aspose一起担任开发人员传播者。