Free Support Forum - aspose.com

How To Design a report with One To Many Mapping?

I ma generating a report in Aspose.Words having one table named Offerings. Now this Offering has got two projects associated with it. i.e. a 1-M relationship. What I am getting in the report is like this

Offering

Project 1

Offering

Project 2

The offering data is getting repeated along with Project data (i.e 2 projects in this case). The requirement is that the offering data is generated only once and the project as many as they are get reflected after the offering details liek this

Offering

Project 1

Project 2

How can I achieve this? Code snippets are welcome.(I am fetching the data for the offering and the related projects from a saingle query and the data gets stored into a datatable). SV please help with this. This one is very urgent.

<span style=“font-size: 12pt; font-family: “Times New Roman”;”>Hi

I think that the same question is answered in:http://www.aspose.com/Community/Forums/thread/91697.aspx


Best regards.<span style=“font-size: 12pt; font-family: “Times New Roman”;”>

Here the issue is that only one merge field has to be pouplated. I am not gettng the hold of how to apply this in my case.

I am adding some of the code here. Please have a look.

private void CreateAsposeReport(DataTable dtOfferings)

{

string str = GetProposedFileName();

Document doc = new Document(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "OfferingandRoadMapReport.doc"));

doc.Protect(ProtectionType.ReadOnly);

doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);

doc.MailMerge.ExecuteWithRegions(dtOfferings);

doc.Save(str, SaveFormat.Doc);

Process.Start(str);

}

private void MailMerge_MergeField(object sender, MergeFieldEventArgs e)

{

if (e.FieldName == "OffId")

{

ObtainData obtData = new ObtainData();

DataTable dtOfferProjects = obtData.GetProjects(Convert.ToInt32(e.FieldValue.ToString()));

foreach (DataRow dr in dtOfferProjects.Rows)

{

e.Document.MailMerge.Execute(dr);

}

}

}

I am not able to understand what I am doing wrong. I am stuck here since days....

Hi

Thanks for additional information. But nested mail merge is not supported by Aspose.Words. Try to use DocumentBuilder to insert data into document during mail merge. See the attachment.

Best regards.

Hi SV,

Thanks for the help. I think I have got the solution.

The issues you have found earlier (filed as 39) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(94)