[英]Convert crystal report to pdf in VB.Net
How to convert Crystal Report to PDF file in VB.Net , 如何在VB.Net中将Crystal Report转换为PDF文件,
I am using Crystal Report Version 10.0.0533 我正在使用Crystal Report版本10.0.0533
My code is 我的代码是
Private Sub ExpData()
If RepRs.BOF Or RepRs.EOF Then
MsgBox("No Details Found", MsgBoxStyle.Information)
RepRs.Close()
Exit Sub
End If
RepRs.MoveFirst()
Dim RepDoc As New ReportDocument
Dim rptLoc As String = ""
rptLoc = My.Application.Info.DirectoryPath & "\Reports\SalesBillACInvoice.rpt"
RepDoc.Load(rptLoc)
RepDoc.SetDataSource(RepRs)
Reports.CRViewer.ReportSource = RepDoc
Reports.Show() 'I want to export here instead of showing...
End Sub
Just do like this, 就这样吧
Created new folder to save PDF files in application startup path, folder name is PDF. 创建了新文件夹以将PDF文件保存在应用程序启动路径中,文件夹名称为PDF。
Remove this line 删除此行
Reports.Show()
Add this code 添加此代码
Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
Dim FilePath As String = Application.StartupPath & "\PDF\" & "SalesBillACInvoice.pdf"
CrDiskFileDestinationOptions.DiskFileName = FilePath
CrExportOptions = RepDoc.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
RepDoc.Export()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
This is the technique I use. 这是我使用的技术。 No server side folder required. 不需要服务器端文件夹。
RepDoc.SetDataSource(RepRs) 'Add dataset to report
RepDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, HttpContext.Current.Response, True, "AttachmentName")
RepDoc.Close()
RepDoc.Dispose()
http://www.c-sharpcorner.com/UploadFile/mahesh/ExportCRtoPDF10062006161918PM/ExportCRtoPDF.aspx http://www.c-sharpcorner.com/UploadFile/mahesh/ExportCRtoPDF10062006161918PM/ExportCRtoPDF.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.