gpt4 book ai didi

.net - 如何在VB.NET中以编程方式将 Crystal 报表导出为PDF

转载 作者:行者123 更新时间:2023-12-04 21:46:00 24 4
gpt4 key购买 nike

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports

Imports System.IO
Imports System.Net
Imports System.Net.Mail

Public Class Form1

Dim cryRpt As New ReportDocument

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

cryRpt.Load("C:\Documents and Settings\Prs1\My Documents\Visual Studio 2008\Projects\myCR\myCR\cr.rpt")
CrystalReportViewer1.ReportSource = cryRpt

CrystalReportViewer1.Refresh()

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

结束类

我试过上面的代码。我的项目文件夹中有一个 Windows 窗体和一个 Crystal 报表文件 (cr.rpt)。我使用 Oracle 10G 作为数据库。
但是我收到一条错误消息,说“登录失败”。 ([错误说明]图片: http://pho.to/Zv6t)

请帮忙。

最佳答案

终于从here找到了解决方法

唯一的问题是,我需要在运行时设置数据库凭据才能使 Crystal Report 正常工作。

cryRpt.SetDatabaseLogon("user", "password", "server", "database")

关于.net - 如何在VB.NET中以编程方式将 Crystal 报表导出为PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14335966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com