Hi,
I have my own class that implements IMailMergeDataSource to manage the data, but it doesn’t execute the function GetChildDataSource when TableStart and TableEnd are inside an IF field.
Thanks.
Hi,
I have my own class that implements IMailMergeDataSource to manage the data, but it doesn’t execute the function GetChildDataSource when TableStart and TableEnd are inside an IF field.
Thanks.
Hi
Thanks for your inquiry. Could you please provide me your template document and simple code, those will allow me to reproduce the problem on my side. I will check the issue and provide you more information.
Best regards,
In this example we obtain two document and fill the table with different information in each document.
You can test this code with the two documents. The one with the IF field will not call GetChildDataSource and will not fill the table.
Public Class Main
Dim DocumentValues As DataTable = New DataTable("DocumentData")
DocumentValues.Columns.Add("NUMDOC", GetType(System.String))
DocumentValues.Rows.Add(New String() {"1"})
DocumentValues.Rows.Add(New String() {"2"})
Dim TableValues As DataTable = New DataTable("TableData")
TableValues.Columns.Add("CODDOC", GetType(System.String))
TableValues.Columns.Add("FIELD1", GetType(System.String))
TableValues.Columns.Add("FIELD2", GetType(System.String))
TableValues.Rows.Add(New String() {"1", "1111", "22222"})
TableValues.Rows.Add(New String() {"1", "33333", "444444"})
TableValues.Rows.Add(New String() {"2", "55", "666666666"})
TableValues.Rows.Add(New String() {"2", "777", "8"})
Dim doc As Document doc = New Document("TableStart_and_TableEnd.doc")
'doc = New Document("TableStart_and_TableEnd_inside_IF.doc")
Dim MyDocDataSource As DocDataSource = New DocDataSource(DocumentValues, TableValues)
doc.MailMerge.Execute(MyDocDataSource)
doc.Save("OutDocument.doc")
End Class
Friend Class DocDataSource
Implements Reporting.IMailMergeDataSource
Private i As Short = -1
Private DocumentData As DataTable Private TableData As DataTable
Public Sub New(ByVal DocValues As DataTable, ByVal TableValues As DataTable)
DocumentData = DocValues
TableData = TableValues
End Sub
Public Function GetChildDataSource(ByVal tableName As String) As Reporting.IMailMergeDataSource Implements Reporting.IMailMergeDataSource.GetChildDataSource
Dim MyTableValues As DataTable = TableData.Clone
Dim j As Short
For j = 0 To TableData.Rows.Count - 1
If TableData.Rows(j)("CODDOC") = DocumentData.Rows(i)("NUMDOC") Then
MyTableValues.Rows.Add(TableData.Rows(j).ItemArray)
End If
Next
Dim MyTableDataSource As TableDataSource = New TableDataSource(MyTableValues)
Return MyTableDataSource
End Function
Public Function GetValue(ByVal fieldName As String, ByRef fieldValue As Object) As Boolean Implements Reporting.IMailMergeDataSource.GetValue
fieldValue = DocumentData.Rows(i)(fieldName)
Return True
End Function
Public Function MoveNext() As Boolean Implements Reporting.IMailMergeDataSource.MoveNext
i = i + 1
If i < DocumentData.Rows.Count Then
Return True
Else
Return False
End If
End Function
Public ReadOnly Property TableName() As String Implements Reporting.IMailMergeDataSource.TableName
Get
Return DocumentData.TableName
End Get
End Property
End Class
Friend Class TableDataSource
Implements Reporting.IMailMergeDataSource
Private i As Short = -1
Private TableData As DataTable
Public Sub New(ByVal TableValues As DataTable)
TableData = TableValues
End Sub
Public Function GetChildDataSource(ByVal tableName As String) As Reporting.IMailMergeDataSource Implements Reporting.IMailMergeDataSource.GetChildDataSource
Return Nothing
End Function
Public Function GetValue(ByVal fieldName As String, ByRef fieldValue As Object) As Boolean Implements Reporting.IMailMergeDataSource.GetValue
fieldValue = TableData.Rows(i)(fieldName)
Return True
End Function
Public Function MoveNext() As Boolean Implements Reporting.IMailMergeDataSource.MoveNext
i = i + 1
If i < TableData.Rows.Count Then
Return True
Else
Return False
End If
End Function
Public ReadOnly Property TableName() As String Implements Reporting.IMailMergeDataSource.TableName
Get
Return TableData.TableName
End Get
End Property
End Class
Hi
Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.
Best regards,
The issues you have found earlier (filed as 14376) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.