send multiple reports to the printer

Stimulsoft Reports.WEB discussion
jpascual
Posts: 68
Joined: Mon Jul 12, 2010 6:45 am
Location: Palencia

send multiple reports to the printer

Post by jpascual »

Hi, I have a report that prints a single report with many dataset that are of a client. The dataset is loaded with a CustomerID.
I can not group the reports by CustomerID, each report is for a customer.

I want to send to print multiple reports for different customers without having to open multiple windows, one for each client.

Is it possible to send multiple reports to the printer queue without opening multiple windows?

thanks!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

send multiple reports to the printer

Post by Alex K. »

Hello,

As a way, you can create multiple reports for different CustomerID, and then merge them into one report and send for printing.

Thank you.
jpascual
Posts: 68
Joined: Mon Jul 12, 2010 6:45 am
Location: Palencia

send multiple reports to the printer

Post by jpascual »

Hi, thanks for your response.

Could you tell me more about how I can combine multiple reports into one?
I can create multiple reports but I do not know how to group.

thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

send multiple reports to the printer

Post by Alex K. »

Hello,

Please see the sample code:

Code: Select all

StiReport report = new StiReport();
report.Load("e:\\Report.mrt");
report.Compile();
report["VariableCustomerID"] = 1;
report.Render(false);

StiReport reportAll = new StiReport();
reportAll.Render();
reportAll.RenderedPages.Clear();

foreach (StiPage page in report.RenderedPages)
{
    reportAll.RenderedPages.Add(page);
}

report["VariableCustomerID"] = 2;
report.Render(false);

foreach (StiPage page in report.RenderedPages)
{
    reportAll.RenderedPages.Add(page);
}

//..
reportAll.Show();
Let us know if you need any additional help.
Thank you.
jpascual
Posts: 68
Joined: Mon Jul 12, 2010 6:45 am
Location: Palencia

send multiple reports to the printer

Post by jpascual »

Hi, I have tried to do what you told me but I can not work. Can you check my code and see what I do wrong?

Code: Select all

                    Dim report As New StiReport
                    report.Load(MapPath("~/Reports/report.mrt"))
                    report.Compile()
                    'report.Render(False)

                    Dim reportAll As New StiReport
                    reportAll.Render()
                    reportAll.RenderedPages.Clear()

                    Dim Customers(2) As String
                    Customers(0) = 719
                    Customers(1) = 717
                    For k = 0 To Customers.Length - 2

                        Dim CustomerID As Integer = Customers(k)
                        Dim DSCustomer As DataSet
                        DSCustomer = CNResid.ShowCustomer(CustomerID)
                        Dim DS2 As New DataSet
                        DS2.Tables.Add(DSCustomer.Tables(0).Copy)

                        report.RegData(DS2)
                        report.Render(False)
                       
                        For Each page As StiPage In report.RenderedPages
                            reportAll.RenderedPages.Add(page)
                        Next
                    Next
                    'reportAll.Show()
                    StiWebViewerFx1.Report = reportAll
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

send multiple reports to the printer

Post by Alex K. »

Hello,

Can you please send us a sample project, which reproduce the issue?

Thank you.
jpascual
Posts: 68
Joined: Mon Jul 12, 2010 6:45 am
Location: Palencia

send multiple reports to the printer

Post by jpascual »

I attach a Visual Studio 2008 project with the code to join two reports into one report. thanks
Attachments
955.Prueba_2ReportIn1.rar
(2.02 MiB) Downloaded 635 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

send multiple reports to the printer

Post by Alex K. »

Hello,

Please check modified project in attachment.

Thank you.
Attachments
958.PruebaPDF.zip
(103.59 KiB) Downloaded 931 times
jpascual
Posts: 68
Joined: Mon Jul 12, 2010 6:45 am
Location: Palencia

send multiple reports to the printer

Post by jpascual »

Thanks for your answer but the example does not work. Displays the report in black and with only one page when it should have two pages and data.
The code is similar to what I had. Just change one line and is similar.

In this example I use variables but usually I use Dataset to load the report. For example:

Dim DSvisualizar As New DataSet
DSvisualizar.Tables.Add(myDatatable.Copy())
report.RegData(DSvisualizar)
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

send multiple reports to the printer

Post by Ivan »

Hello,
jpascual wrote:Thanks for your answer but the example does not work. Displays the report in black and with only one page when it should have two pages and data.
Please modify your code:

Code: Select all

        Dim report As New StiReport
        report.Load(MapPath("~/report.mrt"))
        report.Compile()
        report.Render(False)

        Dim reportAll As New StiReport
        reportAll.NeedsCompiling = False
        reportAll.IsRendered = True
        reportAll.RenderedPages.Clear()

        Dim Customers(2) As String
        Customers(0) = 719
        Customers(1) = 717
        For k As Integer = 0 To Customers.Length - 2

            Dim CustomerID As Integer = Customers(k)
            report("Variable1") = CustomerID.ToString()
            report.Render(False)

            For Each page As StiPage In report.RenderedPages
                reportAll.RenderedPages.Add(page)
            Next
        Next

        StiWebViewerFx1.Report = reportAll
jpascual wrote:The code is similar to what I had. Just change one line and is similar.
This line of code depends on whether the report is compiled or not.

Thank you.
Post Reply