cancel
Showing results for 
Search instead for 
Did you mean: 

Printing / Exporting From Crystal Viewer Produces blank report

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Here's something I was testing out. When I select a date range for only today and export the file, then it exports the data that I see in the viewer. Any other date range that I select, it will only view it but not export it.

former_member183750
Active Contributor
0 Kudos

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-918baefc...

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

Samples

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

Tutorials:

http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/CrystalReports_dotNET_SDK/crsdk_s...

Ludek

Answers (0)