Solved

Vb.net Crystal Report Export to .PDF

Posted on 2008-10-09
5
1,317 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
  • 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 69

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now