Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Printing / Exporting From Crystal Viewer Produces blank report

Hi All,

I have a report that I run. When I select the values and run the report on my web site, it produces data. However, when I go to select the print button or export button on the Crystal Viewer, the exported file that is generated does not display the data that was generated in the Crystal Viewer. How do I successfully generate the export to contain the data that is displayed in the viewer? It seems to default to the values set in my CrystalReportViewer1_Init code.

Here's my code:

Imports CrystalDecisions.Shared

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Web

Partial Class _Default

Inherits System.Web.UI.Page

Dim parameterField As ParameterField

Dim parameterField2 As ParameterField

Dim report As New ReportDocument()

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

display_report()

End Sub

Protected Sub display_report()

parameterField.CurrentValues.Clear()

parameterField2.CurrentValues.Clear()

CrystalReportViewer1.ParameterFieldInfo.Clear()

report.Load("C:\report.rpt")

parameterField = report.ParameterFields("Group")

parameterField2 = report.ParameterFields("Date Range")

For Each li As ListItem In Me.ListBox1.Items

If li.Selected = True Then

' Add all parameters value here

parameterField.CurrentValues.AddValue(li.Value)

End If

Next

parameterField2.CurrentValues.AddRange(CDate(st_date.Text), CDate(en_date.Text), RangeBoundType.BoundInclusive, RangeBoundType.BoundInclusive)

End Sub

Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init

report.Load("C:\report.rpt")

parameterField = report.ParameterFields("Group")

parameterField2 = report.ParameterFields("Date Range")

parameterField.CurrentValues.AddValue("")

parameterField2.CurrentValues.AddRange(Today, Today, RangeBoundType.BoundInclusive, RangeBoundType.BoundInclusive)

CrystalReportViewer1.ReportSource = report

End Sub

End Class

I am using VS 2008 and CR 2008 SP1.

Thank you in advance.

Former Member
replied

Why do you load the report two times? I see report.Load("C: eport.rpt") in the Protected Sub display_report() and in Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs). You should only be loading the report once. Do that before you set any parameters, then set what ever operation you want to do on the report (set parameters, etc.,) and then set the report to the viewer.

Some resources that may help you out:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/702ab443-6a64-2b10-3683-88eb1c3744bc

Samples

https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe

Tutorials:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/CrystalReports_dotNET_SDK/crsdk_samples_aspx/data/crsdk_net_tutorials_115_en.zip

Ludek

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question