Solved

Vb.net Crystal Report Export to .PDF

Posted on 2008-10-09
5
1,330 Views
Last Modified: 2012-05-05
All,
I currently have a block of code below that I created to load a crystal report into a local viewer and pass the required parameters to the crystal report to display the parameters. I was wondering of a way to not load the report into the viewer and automatically export it to a .pdf document. I still need to pass the parameters to the document also. Any help would be greatly appreciated.

Crystal report load:
'Declare new variable to instance of the specified crystal report.

            Me.CrystalReportViewer1.ReportSource = "C:\FrozenDessertVB\fdinspectionreport.rpt"
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
            Dim p_inspection As New ParameterField
            p_inspection.Name = "Inspection"
            Dim p_inspection_Value As New ParameterDiscreteValue
            p_inspection_Value.Value = My.Settings.Inspection_Identity
            p_inspection.CurrentValues.Add(p_inspection_Value)
            ParamFields.Add(p_inspection)
0
Comment
Question by:jpadkins49
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 22681731
Use the reportdocument object and replace this:
Me.CrystalReportViewer1.ReportSource = "C:\FrozenDessertVB\fdinspectionreport.rpt"
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo

with this:

Dim cr As New CrystalDecisions.CrystalReports.Engine.ReportDocument
cr.load("C:\FrozenDessertVB\fdinspectionreport.rpt")
Dim ParamFields As ParameterFields = cr.ParameterFields

if you need to view it as well:
CrystalReportViewer1.Reportsource = cr
 
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22683463
0
 
LVL 1

Author Comment

by:jpadkins49
ID: 22690929
UnifiedIS:
Is there another step that I need to take to automatically export the document to .pdf. I will try this when I return home later and see.
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 total points
ID: 22701924
After adding your parameters, use cr.ExporttoDisk

cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, filepath)
0
 
LVL 1

Author Closing Comment

by:jpadkins49
ID: 31507818
This solution worked like a charm. Sorry it took so long for me to respond.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question