2013-01-08 63 views
1

我是VB和Crystal Reports的新手。我想在VB.NET中創建一個不使用表單的文件.exe在vb中將水晶報表導出爲pdf,而不使用表格

我正在使用Visual Studio 2010. .exe文件只是純粹用於將Crystal Report導出到.pdf文件,我應該從哪裏啓動?

我應該使用console application嗎?我想使用empty project code

我搜查了互聯網,找不到任何參考。

請讓我知道是否有我可以參考的參考。

回答

1

您可能可能使用控制檯應用程序或表單應用程序,但只是不顯示窗體。我傾向於在指向人的代碼示例:http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm

Imports CrystalDecisions.CrystalReports.Engine 
Imports CrystalDecisions.Shared 
Public Class Form1 
    Dim cryRpt As New ReportDocument 

    Private Sub Button1_Click(ByVal sender As System.Object, _ 
    ByVal e As System.EventArgs) Handles Button1.Click 
     cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt") 
     CrystalReportViewer1.ReportSource = cryRpt 
     CrystalReportViewer1.Refresh() 
    End Sub 

    Private Sub Button2_Click(ByVal sender As System.Object, _ 
    ByVal e As System.EventArgs) Handles Button2.Click 
     Try 
      Dim CrExportOptions As ExportOptions 
      Dim CrDiskFileDestinationOptions As New _ 
      DiskFileDestinationOptions() 
      Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions() 
      CrDiskFileDestinationOptions.DiskFileName = _ 
             "c:\crystalExport.pdf" 
      CrExportOptions = cryRpt.ExportOptions 
      With CrExportOptions 
       .ExportDestinationType = ExportDestinationType.DiskFile 
       .ExportFormatType = ExportFormatType.PortableDocFormat 
       .DestinationOptions = CrDiskFileDestinationOptions 
       .FormatOptions = CrFormatTypeOptions 
      End With 
      cryRpt.Export() 
     Catch ex As Exception 
      MsgBox(ex.ToString) 
     End Try 
    End Sub 
End Class 
+0

感謝ü非常lee.Now我能有一個breif想法。 –