Using external report as a subreport.

Stimulsoft Reports.NET discussion
Pilgrim
Posts: 29
Joined: Fri Aug 03, 2007 7:57 am
Location: Cape Town

Using external report as a subreport.

Post by Pilgrim »

Good day.

I want to know if it is possible to use an external report (e.g. a one page report that displays a clients details) as a subreport in another report.

What I want to do is have a report list all the clients then for each client load the external report that displays the details.

That way we can reuse the client details report on other reports.

(generic example, we want to create hundreds of little reports that we can use on a few big reports and perhaps use those big reports in a huge month end report)

Thank you :biggrin:
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Using external report as a subreport.

Post by Vital »

Hello!

You can try use property SubReports of StiReport. Please see attached sample project.

Thank you.
Attachments
SubReports.zip
(6.28 KiB) Downloaded 725 times
Pilgrim
Posts: 29
Joined: Fri Aug 03, 2007 7:57 am
Location: Cape Town

Using external report as a subreport.

Post by Pilgrim »

That is really awesome.

Now I just have one more question.

Is there a way to use a data list to load sub reports?

I want to create a sub report that displays details depending on a "parameter" and a data list that generates that "parameter"

I want to list all the products bought by a client and pass the product code for each product to the product details reports.

Then I want to create a report that creates this report for all our active clients.

But what is really important is that I want to use external reports for each step. I may want to use the product details on its own, or run a single client report.

I really look forward to your reply.

Thanks.
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Using external report as a subreport.

Post by Guest »

We will add this possibility on 9 August.

Thank you.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Using external report as a subreport.

Post by Vital »

You can check build from 10 August. Set new property UseExternalReport to true. property SubReportPage to null. After then you need add event handler to event GetSubReport of StiReport object:

Code: Select all

private void OnGetSubReport(object sender, StiGetSubReportEventArgs e)
		{
			StiReport report = new StiReport();
			report.Load("d:\\SimpleGroup.mrt");
			DataSet data = new DataSet();
			data.ReadXml("d:\\demo.xml");
			data.ReadXmlSchema("d:\\demo.xsd");

			report.RegData("Demo", data);

			e.Report = report;
		}


report.GetSubReport += new StiGetSubReportEventHandler(OnGetSubReport);

Also you need detect current line of specified datasource. You can use following code in event handler:

Code: Select all

StiReport parentReport = sender as StiReport;
StiDataSource data = parentReport.Dictionary.DataSources["MyDataSource"];
object value = data["MyColumn"];
Received value you can use as variable in subreport.

Thank you.
Pilgrim
Posts: 29
Joined: Fri Aug 03, 2007 7:57 am
Location: Cape Town

Using external report as a subreport.

Post by Pilgrim »

Thank you very much!

I will implement it this weekend :grinder:
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Using external report as a subreport.

Post by Guest »

If you will have any problems, please, inform us, because this option is a new.

Thank you.
Pilgrim
Posts: 29
Joined: Fri Aug 03, 2007 7:57 am
Location: Cape Town

Using external report as a subreport.

Post by Pilgrim »

Hi Pavel.

I cannot get the external subreports to work. :dumb:

Can you perhaps send me a sample project?

Thanks.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using external report as a subreport.

Post by Edward »

The problem is fixed. Fix will be available in the build from August, 23.

Thank you.
Pilgrim
Posts: 29
Joined: Fri Aug 03, 2007 7:57 am
Location: Cape Town

Using external report as a subreport.

Post by Pilgrim »

Hi Guys.

I updated to the newest version of Stimulsoft and now subreporting does not work any more.

Code: Select all

 Dim parentReport As Stimulsoft.Report.StiReport = TryCast(sender, Stimulsoft.Report.StiReport)
            If parentReport Is Nothing Then
                Exit Sub
            End If

            Dim comp As Stimulsoft.Report.Components.StiComponent = parentReport.GetComponentByName(e.SubReportName)
            If comp Is Nothing Then
                Exit Sub
            End If

            Dim dataBand As Stimulsoft.Report.Components.StiDataBand = comp.GetDataBand()
            If dataBand Is Nothing Then
                'This subreport is not on an databand. Just display it.

            Else
                'Databand found.
                Dim data As Stimulsoft.Report.Dictionary.StiDataSource

                data = parentReport.Dictionary.DataSources(dataBand.DataSourceName)
                If data Is Nothing Then
                    Exit Sub
                End If

                Dim value As Object = data("CODE")
                If value Is Nothing Then
                    Exit Sub
                End If
                Debug.WriteLine(data.Position & " ->" & value.ToString)
            End If
The data.position stays at 0. Any idea what is going on?

Thanks.
Post Reply