1

我是 VB 和 Crystal Reports 的新手。

我想.exe在 VB.NET 中创建一个不使用表单的文件。

我正在使用 Visual Studio 2010。该.exe文件只是纯粹用于将 Crystal Report 导出到.pdf文件中,我应该从哪里开始?

我应该使用console application吗?

我应该使用empty project code吗?

我搜索了互联网,找不到任何参考资料。

请让我知道是否有我可以参考的参考。

4

1 回答 1

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
于 2013-01-09T09:45:16.520 回答