Results 1 to 10 of 10

Thread: [RESOLVED] [2005] Hi, how to create automatically pdf report based on crystal report data

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Resolved [RESOLVED] [2005] Hi, how to create automatically pdf report based on crystal report data

    hi, based on the data displayed in the crystal report...
    i wanted to automatically make it as pdf report..

    codes below is work perfectly.. how could i create a .pdf report when i click create pdf button and save it to c: drive how to do..?

    here is my codes:
    Code:
     Private Sub ConnectionPrint()
            If cnReport.State = ConnectionState.Closed Then
                cnReport = New OleDbConnection
                cnReport.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Data\RSODB.mdb;User Id=admin;Password=;"
                cnReport.Open()
            End If
    
        End Sub
    
       Private Sub GetRecords() '(ByVal myRSONOfilter As String)
            myRSONOfilterReport = Me.TextBox1.Text
            dsReport.Clear()
            dsReport = New DataSet
            daReport = New OleDbDataAdapter("Select * from FinalReportV2 where RSONO=" & myRSONOfilterReport & "", cnReport)
            daReport.Fill(dsReport, "FinalReportV2")
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Priview.Click
    
            ConnectionPrint()
            GetRecords()
    
            ' Fill the DataSet.
            daReport.Fill(dsReport)
    
            ' Make a report and bind the DataSet to it.
            Dim rpt As New CrystalFinalOff
            rpt.SetDataSource(dsReport)
    
            ' Bind the viewer to the report.
            CrystalReportViewer1.ReportSource = rpt
            'CrystalReportViewer1.PrintReport()
    
        End Sub
    Please help...
    Last edited by edgarbenilde; Jul 30th, 2008 at 01:51 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    There is an Export class which you call call to export the report to a pdf depending upon the required arguments.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    yes i tried it but what i wanted to have is automatically generate the pdf report and save it to the c drive because the reason why i ave to save it c drive beacause i want to automaitcally send it by email as an attachment...

    someone help me here please..

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    There should be an ExportToDisk method which you can set up with the path to export the pdf to. Post you code you have so far.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    I can't continue here..

    as of now under button1 i have this code..

    Code:
    
    
            ConnectionPrint()
            GetRecords()
    
            ' Fill the DataSet.
            daReport.Fill(dsReport)
    
            ' Make a report and bind the DataSet to it.
            Dim rpt As New CrystalFinal
            rpt.SetDataSource(dsReport)
    
            ' Bind the viewer to the report.
            CrystalReportViewer1.ReportSource = rpt
            CrystalReportViewer1.ExportReport()
            'CrystalReportViewer1.PrintReport()
    
    
    
            Dim CrystalOptions As [Shared].ExportOptions
    
    
    
    'i have error on this line of code below..
    
            CrystalOptions = rpt.ExportOptions
            CrystalOptions.ExportDestinationType = "C;\"
            CrystalOptions.ExportFormatOptions
            CrystalOptions.FormatTyp = crEFTWordForWindows

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    Someone help me please..?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    Hi, someone help please how could i export data in my crystal report to pdf file and save it to c drive..


    please help..

  8. #8
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    Please convert this code in VB.

    Code:
    //Imports
    using CrystalDecisions.CrystalReports;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using System.IO;
    Code:
    string exportFilePath = Server.MapPath("myfile.pdf");
    
    ReportDocument oRpt = new ReportDocument();
    
    oRpt.Load(Server.MapPath("Reports/MyReport.rpt"));
    
    DiskFileDestinationOptions oDest = new DiskFileDestinationOptions();
    oDest.DiskFileName = exportFilePath;
    
    ExportOptions oExport = oRpt.ExportOptions;
    
    oExport.ExportDestinationOptions = oDest;
    
    oExport.ExportDestinationType = ExportDestinationType.DiskFile;
    
    oExport.ExportFormatType = ExportFormatType.PortableDocFormat;
    
    ParameterFields pFields = new ParameterFields();
    ParameterField pField = new ParameterField();
    ParameterDiscreteValue disVal = new ParameterDiscreteValue();
    ParameterRangeValue rVal = new ParameterRangeValue();
    		
    // If you have parameter
    pField.ParameterFieldName = "@ID";
    
    // Value of the parameter
    disVal.Value = "100";
    pField.CurrentValues.Add(disVal);
    
    pFields.Add(pField);
    
    string serverName = "SERVER_NAME";
    string databaseName = "DATABASE_NAME";
    string userName = "USER_NAME";
    string password = "PASSWORD";
    oRpt.SetDatabaseLogon(userName,password,databaseName,databaseName,true);				
    
    oRpt.SetParameterValue("@ID","100");
    
    oRpt.Export();
    Thanks.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    Thanks USAMAALAM, but i don't know how to convert on it to c# manually
    i tried to use online converter but there is error on line 6 EOF error...

    can u try to convert on it into vb .net for me..? thanks..

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: [2005] Hi, how to create automatically pdf report based on crystal report data

    Thank for all reply..
    i got it the way i wanted to be with the snippets help....

    here is my code below..

    Code:
          Private Sub GetRecords() '(ByVal myRSONOfilter As String)
            myRSONOfilterReport = Me.TextBox1.Text
            dsReport.Clear()
            dsReport = New DataSet
            daReport = New OleDbDataAdapter("Select * from FinalReportV2 where RSONO=" & myRSONOfilterReport & "", cnReport)
            daReport.Fill(dsReport, "FinalReportV2")
        End Sub
        Private Sub ConnectionPrint()
            If cnReport.State = ConnectionState.Closed Then
                cnReport = New OleDbConnection
                cnReport.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\rso\Rsodb.mdb;User Id=admin;Password=;"
                cnReport.Open()
            End If
    
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Priview.Click
    
            ConnectionPrint()
            GetRecords()
    
            ' Fill the DataSet.
            daReport.Fill(dsReport)
    
            ' Make a report and bind the DataSet to it.
            Dim rpt As New CrystalFinal
            rpt.SetDataSource(dsReport)
    
            ' Bind the viewer to the report.
            CrystalReportViewer1.ReportSource = rpt
            'CrystalReportViewer1.ExportReport()
            'CrystalReportViewer1.PrintReport()
    
    
            Dim report As New CrystalFinal()
            Dim exportOptions As New ExportOptions()
            Dim pdfExportFormatOptions As New PdfRtfWordFormatOptions()
            Dim diskDestinationOptions As New DiskFileDestinationOptions()
    
            ' Set the export format and format options
            exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
            pdfExportFormatOptions.FirstPageNumber = 1
            pdfExportFormatOptions.LastPageNumber = 5
            pdfExportFormatOptions.UsePageRange = True
            exportOptions.ExportFormatOptions = pdfExportFormatOptions
    
            ' Set the disk file options.
            exportOptions.ExportDestinationType = ExportDestinationType.DiskFile
            diskDestinationOptions.DiskFileName = "C:\RSO  " & Me.TextBox1.Text & ".pdf"
            exportOptions.DestinationOptions = diskDestinationOptions
    
            ' report.Load("rpt.rpt")
            report.Export(exportOptions)
            report.Close()
    
        End Sub
    Last edited by edgarbenilde; Sep 4th, 2008 at 06:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width