我是VB和Crystal Reports的新手。
我想在VB.NET中创建一个不使用Form的.exe
文件。
我正在使用Visual Studio 2010。
.exe
文件仅用于将Crystal Report导出到.pdf
文件中,我应该从哪里开始?
我应该使用console application
吗?
我应该使用empty project code
吗?
我在互联网上搜索过,找不到任何参考资料。
如果有参考资料,请告诉我。
答案 0 :(得分: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