Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 22nd, 2003, 01:38 PM
Registered User
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Oppie
Default Export report with parameters via PDF

Good afternoon,

I am creating a report website with asp.net and crystal.net. I have been successful in getting all of my reports to display correctly within the viewer, but I can not export them in any format, preferably PDF. I was able to pass the parameters to the viewer, but I can't seem to get the parameters to the export procedure. Does anyone have a clue how to pass the parameters that I have in this code below to the export procedure? I would like for the user to view the report within the webpage and then be able to click a PDF button that will send the report to the Acrobat Plug-In so the user may print or save the report.

crReportDocument1 = New PendingDisbRpt
crvReports.ReportSource = crReportDocument1
''Get the collection of parameters from the report
crParameterFields = crvReports.ParameterFieldInfo
''Access the specified parameter from the collection
crParameterField = crParameterFields.Item("BANK")
crParameterValues = crParameterField.CurrentValues
''Set the current values for the parameter field
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = subLenderID
''Add the first current value for the parameter field
''Access the specified parameter from the collection.
''This parameter is a Range parameter
crParameterField = crParameterFields.Item("DATE")
''Get the current values from the parameter field.
''At this point there are zero values set.
crParameterValues = crParameterField.CurrentValues
crParameterRangeValue = New ParameterRangeValue
''Set the current values for the Start and End valuse of the
''parameter field
With crParameterRangeValue
    .EndValue = subDisbEndDt
    .LowerBoundType = RangeBoundType.BoundInclusive
    .StartValue = subDisbStDt
    .UpperBoundType = RangeBoundType.BoundInclusive
End With
''Add the range current value for the parameter field
crvReports.ParameterFieldInfo = crParameterFields


Reply With Quote
  #2 (permalink)  
Old November 12th, 2003, 09:26 PM
Registered User
Join Date: Nov 2003
Location: , , Australia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

I know this is an old post from last month, however....

I have had the exact same issue with a project that I am working on. I have solved this - are you still looking for a solution?

Reply With Quote
  #3 (permalink)  
Old November 27th, 2003, 12:31 PM
Registered User
Join Date: Nov 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

I have the same problem today.
Any chance of you sharing your fix ? - please ...


Reply With Quote
  #4 (permalink)  
Old November 27th, 2003, 06:53 PM
Registered User
Join Date: Nov 2003
Location: , , Australia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

Here is how I did it. This code is from the Page_Load event.

        Dim crExportOptions As ExportOptions
        Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
        Dim fname As String

        Dim MyTableLogOnInfo As CrystalDecisions.Shared.TableLogOnInfo
        'CrystalDecisions.Shared.TableLogOnInfo MyTableLogOnInfo;
        Dim MyConnectionInfo As New ConnectionInfo()
        'ConnectionInfo MyConnectionInfo;

        ''create a ReportDocument and load the CR report file...
        Dim MyReportDocument As New ReportDocument()
        'ReportDocument MyReportDocument = new ReportDocument();
        ''set up connection information (the password isn't kept in the report file)...
        'MyConnectionInfo = new ConnectionInfo();
        MyConnectionInfo.Password = "password"
        Dim T As CrystalDecisions.CrystalReports.Engine.Table
        For Each T In MyReportDocument.Database.Tables
            MyTableLogOnInfo = T.LogOnInfo
            MyTableLogOnInfo.ConnectionInfo = MyConnectionInfo

        'set the viewer's report source...
        'crvSample.ReportSource = MyReportDocument
        Dim field As New CrystalDecisions.Shared.ParameterValues()
        Dim value As New CrystalDecisions.Shared.ParameterDiscreteValue()

        value.Value = 1


        'Export the file instead.
        fname = "c:\export\" & Session.SessionID.ToString & ".pdf"
        crDiskFileDestinationOptions = New DiskFileDestinationOptions()
        crDiskFileDestinationOptions.DiskFileName = fname
        crExportOptions = MyReportDocument.ExportOptions
        With crExportOptions
            .DestinationOptions = crDiskFileDestinationOptions
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.PortableDocFormat
        End With


        Response.ContentType = "application/pdf"
This code exports the report to a PDF file, and then loads the PDF file into the browser.

If you find anymore to add to the discussion, please post it here. I was working on this stuff as research for a project for one of my clients. They have since canned it, and I don't have time to examine it further.


Reply With Quote
  #5 (permalink)  
Old November 27th, 2003, 07:00 PM
Registered User
Join Date: Nov 2003
Location: , , Australia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

Further to the above, note that I could not seem to combine the Viewer and its parameters with exporting, and exporting without the viewer handles parameters differently...

Reply With Quote
  #6 (permalink)  
Old December 15th, 2003, 02:25 PM
Registered User
Join Date: Dec 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

i have this code, and it works for me.
it loads querystring params as the report params,
they just need to have all the same names. the
rpt querystring is taken as the report object's name,
any and all others get taken as reportparams.
cheers, and good luck.
no time for explanations, dr. jones.


Imports System.IO
    Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
        Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
        Dim crExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim OutputFile As String 'full path to destination file, minus extension
        Dim OutputURL As String ' URL of output file

        Dim loop1, loop2 As Integer
        Dim arr1(), arr2() As String
        Dim coll As System.Collections.Specialized.NameValueCollection

        crReportDocument.Load(Server.MapPath(Request.Query String("rpt") + ".rpt"))
        coll = Request.QueryString
        arr1 = coll.AllKeys
        For loop1 = 0 To arr1.GetUpperBound(0)
            arr2 = coll.GetValues(loop1)
            If (arr1(loop1) <> "rpt") Then
                crReportDocument.SetParameterValue("@" + arr1(loop1), arr2(0))
            End If
        Next loop1

        crReportDocument.SetDatabaseLogon("mylogin", "mypwd", "myhost", "mydb")

        crExportOptions = crReportDocument.ExportOptions
        crExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableD ocFormat
        OutputFile = Server.MapPath(".\ExportedReports\" & Request.QueryString("rpt") & ".pdf")
        OutputURL = "./ExportedReports/" & Request.QueryString("rpt") & ".pdf"
        If File.Exists(OutputFile) Then
        End If
        Dim crDiskFileDestinationOptions As New CrystalDecisions.Shared.DiskFileDestinationOptions

        'The ASPNET user account must have Modify (Read & Write) permissions on the export directory

        crDiskFileDestinationOptions.DiskFileName = OutputFile
        With crExportOptions
            .DestinationOptions = crDiskFileDestinationOptions
            .ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.Disk File
        End With
    End Sub

Reply With Quote
  #7 (permalink)  
Old March 2nd, 2005, 02:19 PM
Registered User
Join Date: Mar 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

How to overcome this problem.I face that in Visual Studio 2003.
Please give your suggestions ASAP.


Reply With Quote
  #8 (permalink)  
Old March 14th, 2005, 10:57 AM
Registered User
Join Date: Mar 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hi, I am now using ASP.NET with to do a project. I used Crystal Report to generate reports. My problem is, when I generate a report and able to export it into PDF, MS Word and MS Exel file, it could not export the content of report. The PDF just shows the header of report only. Any one know why the content were not exported together?

I need to solve this problem urgently, please help.


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Crystal Report to PDF aarunlal ASP.NET 2.0 Professional 1 June 28th, 2006 01:18 PM
Export to PDF problem with crystal report in c# fidelio ASP.NET 1.0 and 1.1 Professional 0 April 12th, 2006 07:34 AM
Export Report into PDF format raksha Crystal Reports 0 May 11th, 2005 09:32 AM
Crystal Report 8.5 Export to PDF problem DragonSon Crystal Reports 0 August 17th, 2004 10:32 PM
Pdf Crystal Report export Kristoff Crystal Reports 1 October 21st, 2003 09:38 AM

All times are GMT -4. The time now is 11:53 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.