Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Crystal_Report

Crystal_Report

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simworld
    wrote on last edited by
    #1

    I represented the data in Crystal Report based on certain conditions. which is stored in a table "abc" . I used CrystalReportViewer Control and my Crystal Report name is crystalreport1.rpt . and control name is crystalreportviewer1 I have a task to convert that report into pdf file and save into a folder(output) in Drive C: . and also to open that pdf file after creating the pdf. My question is what will be the C# code to convert Crystal Report into pdf files and stored in that folder of drive C: .

    S P 2 Replies Last reply
    0
    • S simworld

      I represented the data in Crystal Report based on certain conditions. which is stored in a table "abc" . I used CrystalReportViewer Control and my Crystal Report name is crystalreport1.rpt . and control name is crystalreportviewer1 I have a task to convert that report into pdf file and save into a folder(output) in Drive C: . and also to open that pdf file after creating the pdf. My question is what will be the C# code to convert Crystal Report into pdf files and stored in that folder of drive C: .

      S Offline
      S Offline
      SABhatti
      wrote on last edited by
      #2

      I have converted this code from vb without testing, so please correct any syntax error ... DiskFileDestinationOptions DiskOpts = New DiskFileDestinationOptions(); // export options to hard disk // oReport is a ReportDocument oReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile; // export option TYPE oReport.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat; // PDF file location and filename DiskOpts.DiskFileName = ExportPath + requiredFilename; // Destination options oReport.ExportOptions.DestinationOptions = DiskOpts; // Export oReport.Export(); // clear cr viewer and report document crViewer.ReportSource = null; oReport.Dispose(); oReport = null; // do this if you want to give the option to save or download the file, other wise go to Response.Redirect line at the end Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment; filename=filename.pdf"); Response.ContentType = "application/pdf"; Response.WriteFile(ExportPath + requiredFilename); Response.End(); // if you just want to open the the file then just do this and skip the above lines from Response.Clear to Response.End Response.Redirect(pdffilenameandpath, true);

      -----

      S 1 Reply Last reply
      0
      • S simworld

        I represented the data in Crystal Report based on certain conditions. which is stored in a table "abc" . I used CrystalReportViewer Control and my Crystal Report name is crystalreport1.rpt . and control name is crystalreportviewer1 I have a task to convert that report into pdf file and save into a folder(output) in Drive C: . and also to open that pdf file after creating the pdf. My question is what will be the C# code to convert Crystal Report into pdf files and stored in that folder of drive C: .

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        A few statements from how I run a Crystal Report via a Windows Service: Defile is a FileInfo indicating the RPT file. reportfile is a FileInfo indicating the destination for the PDF.

        CrystalDecisions.CrystalReports.Engine.ReportDocument crRpt =
        new CrystalDecisions.CrystalReports.Engine.ReportDocument() ;
        crRpt.Load ( Defile.FullName ) ;

        crRpt.SetParameterValue
        (
        parm.Key
        ,
        parm.Value
        ) ;

        crRpt.ExportToDisk
        (
        CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
        ,
        reportfile.FullName
        ) ;

        1 Reply Last reply
        0
        • S SABhatti

          I have converted this code from vb without testing, so please correct any syntax error ... DiskFileDestinationOptions DiskOpts = New DiskFileDestinationOptions(); // export options to hard disk // oReport is a ReportDocument oReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile; // export option TYPE oReport.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat; // PDF file location and filename DiskOpts.DiskFileName = ExportPath + requiredFilename; // Destination options oReport.ExportOptions.DestinationOptions = DiskOpts; // Export oReport.Export(); // clear cr viewer and report document crViewer.ReportSource = null; oReport.Dispose(); oReport = null; // do this if you want to give the option to save or download the file, other wise go to Response.Redirect line at the end Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment; filename=filename.pdf"); Response.ContentType = "application/pdf"; Response.WriteFile(ExportPath + requiredFilename); Response.End(); // if you just want to open the the file then just do this and skip the above lines from Response.Clear to Response.End Response.Redirect(pdffilenameandpath, true);

          -----

          S Offline
          S Offline
          simworld
          wrote on last edited by
          #4

          Is there any dll file needed to convert into PDF

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups