Solved

Vb.net Crystal Report Export to .PDF

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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