vb.net 在vb中将水晶报告导出为pdf而不使用表单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14220475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Export crystal report into pdf in vb without using form
提问by Hafiz Jeremy Kurt Manget
I'm a newbie to VB and Crystal Reports.
我是 VB 和 Crystal Reports 的新手。
I want to make an .exefile in VB.NET that doesn't use a Form.
我想.exe在 VB.NET 中创建一个不使用表单的文件。
I'm using Visual Studio 2010.
The .exefile is just purely for exporting a Crystal Report into a .pdffile, where should I start?
我使用的是 Visual Studio 2010。该.exe文件仅用于将 Crystal Report 导出到.pdf文件中,我应该从哪里开始?
Should I use the console application?
我应该使用console application?
Should I use the empty project code?
我应该使用empty project code?
I have searched the internet and cannot find any references.
我在互联网上搜索过,找不到任何参考资料。
Please let me know if there is a Reference that I can refer to.
请让我知道是否有我可以参考的参考。
回答by Lee Tickett
You could probably use a console app or a forms app but just don't display the form. I tend to point people to the code samples at: http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm
您可能会使用控制台应用程序或表单应用程序,但只是不显示表单。我倾向于将人们指向代码示例: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

