this is my function and exccution halt at document.MailMerge.ExecuteWithRegions(dataTable) .
kindly give me reply as soon as possible
Public Overrides Sub GenerateDocument()
If Me.TemplatePath Is Nothing OrElse _
Me.TemplatePath.Trim.Equals("") Then
Throw New Exception("Template path not set.")
End If
' set license
Dim licenseFile As String = ConfigurationSettings.AppSettings("AsposeLicenseFile")
If (Not licenseFile Is Nothing) AndAlso (Not String.Empty.Equals(licenseFile)) Then
If Not Me.HttpContext Is Nothing Then
' called from webui; map virtual path to physical path
licenseFile = Me.HttpContext.Server.MapPath(Me.HttpContext.Request.ApplicationPath & licenseFile)
End If
Dim asposeWordLicense As New Aspose.Word.License
asposeWordLicense.SetLicense(licenseFile)
Dim asposePdfLicense As New Aspose.Pdf.License
asposePdfLicense.SetLicense(licenseFile)
'Added by Arvind for EXCEL
Dim asposeExcelLicense As New Aspose.Excel.License
asposeExcelLicense.SetLicense(licenseFile)
'End
End If
' added by arun puthran on 19-oct-2005; try catch for ObjectDisposedException error
' Create new document from the Template
Dim document As Aspose.Word.Document
'Added by Arvind for Excel
Dim designer As ExcelDesigner
Try
If Not Me.OutputType = OutputType.EXCEL Then
document = New Aspose.Word.Document(Me.TemplatePath)
End If
'Added by Arvind for EXCEL
If Me.OutputType = OutputType.EXCEL Then
designer = New ExcelDesigner
Dim designerFile As String = Me.TemplatePath
designer.Open(designerFile)
End If
''End
Catch ex As System.ObjectDisposedException
' ignore ObjectDisposedException error
End Try
' set repetitive fields
If Me.Relation Is Nothing AndAlso _
(Me.Relations Is Nothing OrElse Me.Relations.Count = 0) Then
' No master- child relation
Dim enumerator As IDictionaryEnumerator = Me.DocumentTableList.GetEnumerator()
While enumerator.MoveNext
Dim dataTable As System.Data.DataTable = enumerator.Value
If Not Me.OutputType = OutputType.EXCEL Then
document.MailMerge.ExecuteWithRegions(dataTable) // Exceution halt at this point
End If
'Added by Arvind for EXCEL
If Me.OutputType = OutputType.EXCEL Then
designer.SetDataSource(dataTable)
designer.SetDataSource(Me.StaticFieldsList)
End If
'end
End While
ElseIf (Not Me.Relations Is Nothing) AndAlso (Me.Relations.Count > 1) Then
If Not Me.OutputType = OutputType.EXCEL Then
Dim dstDoc As Aspose.Word.Document = document.Clone()
dstDoc.Sections.Clear()
Me.IsFirstPage = True
For Each relation As DataRelation In Me.Relations
ProcessRelation(relation, document, dstDoc)
Next
InsertHeader(dstDoc)
document = dstDoc
End If
'Added by Arvind for EXCEL
If Me.OutputType = OutputType.EXCEL Then
ProcessExcelRelations(Me.Relation, designer)
End If
'End
ElseIf Not Me.Relation Is Nothing Then
If Not Me.OutputType = OutputType.EXCEL Then
Dim dstDoc As Aspose.Word.Document = document.Clone()
dstDoc.Sections.Clear()
ProcessRelation(Me.Relation, document, dstDoc)
InsertHeader(dstDoc)
document = dstDoc
End If
If Me.OutputType = OutputType.EXCEL Then
ProcessExcelRelation(Me.Relation, designer)
End If
End If
' set static fields
If Not Me.StaticFieldsList Is Nothing Then
If Not Me.OutputType = OutputType.EXCEL Then
If document.Sections.Count.Equals(0) Then
Throw New Exception(Constants.NoRecordsFound)
End If
document.MailMerge.Execute(Me.StaticFieldsList)
End If
End If
Select Case Me.SaveType
Case SaveType.Save
If Not Me.OutputType = OutputType.EXCEL Then
Save(document, Me.OutputType)
End If
'Added by Arvind for Excel
If Me.OutputType = OutputType.EXCEL Then
SaveExcel(designer)
End If
'end
Case SaveType.Browser
If Not Me.OutputType = OutputType.EXCEL Then
SendToBrowser(document, Me.OutputType)
End If
'Added by Arvind for Excel
If Me.OutputType = OutputType.EXCEL Then
SaveExcel(designer)
End If
'end
Case SaveType.SaveAndBrowser
If Not Me.OutputType = OutputType.EXCEL Then
Save(document, Me.OutputType)
SendToBrowser(document, Me.OutputType)
End If
'Added by Arvind for Excel
If Me.OutputType = OutputType.EXCEL Then
SaveExcel(designer)
End If
'end
End Select
End Sub