Ticket T319008
Visible to All Users

An empty report can be produced when loading a report data and printing XtraReport programmatically

created 9 years ago

[DevExpress Support Team: CLONED FROM Q336182: How to print report direct, and print preview via an simple action?]
Hi,
I have tried this:
Dim reportData As IReportDataV2 = DirectCast(ObjectSpace.FindObject(Application.Modules.FindModule(Of ReportsModuleV2)().ReportDataType, New BinaryOperator("DisplayName", "Bill")), IReportDataV2)
     Dim report = ReportDataProvider.ReportsStorage.LoadReport(reportData)
     With report
        report.RequestParameters = False
        report.Parameters("p_key").Value = hdr.bill_hdr_key

Dim printTool As New ReportPrintTool(report)
        printTool.Print()
     End With
Why is it printing a blank report even if it has properly passed the value of the parameter?  What am I missing?

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello Voxdei,

As I see, you forgot to call the reportsModule.ReportsDataSourceHelper.SetupBeforePrint(report) method before printing your report.
Please check out the eXpressApp Framework > Task-Based Help > How to: Print a Report Without Displaying a Preview  article for more details.

    Comments (2)

      Thanks for your help Dennis, I have modified the code accordingly and it works fine now.  The revised code is:
           Dim reportData As IReportDataV2 = DirectCast(ObjectSpace.FindObject(Application.Modules.FindModule(Of ReportsModuleV2)().ReportDataType, New BinaryOperator("DisplayName", "Bill")), IReportDataV2)
           Dim report = ReportDataProvider.ReportsStorage.LoadReport(reportData)
           Dim reportsModule As ReportsModuleV2 = ReportsModuleV2.FindReportsModule(Application.Modules)
           Dim printTool As New ReportPrintTool(report)
           With report
              report.RequestParameters = False
              report.Parameters("p_key").Value = hdr.bill_hdr_key
              reportsModule.ReportsDataSourceHelper.SetupBeforePrint(report)
              printTool.Print()
           End With

      Dennis Garavsky (DevExpress) 9 years ago

        Great, thanks for informing me of your results.

        Regards,
        Dennos
        News, tips & tricks and other interesting information about DevExpress Application Framework and ORM directly from the lab.

        P.S.
        Do not miss our team news for the upcoming v15.2 release: https://community.devexpress.com/blogs/eaf/default.aspx
        This may be interesting for you as well: https://www.devexpress.com/Products/NET/Application_Framework/xaf-community.xml

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.