Solved

Vb.net Crystal Report Export to .PDF

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 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