日期:2014-05-20  浏览次数:20510 次

crystal report 转换成PDF的问题
想问一下vs2003的crystal   report中有什么方法可把报表转换成PDF格式?

------解决方案--------------------
我写的一个函数:

Public Sub ExportToDisk(ByVal fileName As String, ByVal Report As ReportDocument, ByVal intType As Integer)
Dim htmlOpts As New HTMLFormatOptions
'dim i as New
Dim exportOpts As New ExportOptions
Dim diskOpts As New DiskFileDestinationOptions
exportOpts = Report.ExportOptions
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile

Select Case intType
Case 1 '生成PDF
If System.IO.File.Exists(fileName) Then
Try
File.Delete(fileName)
Catch ex As Exception
Dim strErr As String
strErr = ex.ToString
End Try
Else
End If
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
diskOpts.DiskFileName = fileName
Case 2 '生成Word
If System.IO.File.Exists(fileName) Then
Try
File.Delete(fileName)
Catch ex As Exception
Dim strErr As String
strErr = ex.ToString
End Try
Else
End If
exportOpts.ExportFormatType = ExportFormatType.WordForWindows
diskOpts.DiskFileName = fileName
Case 3 '生成Html 有错误
'If System.IO.File.Exists(FolderName) Then
' File.Delete(FolderName)
'Else
'End If
'With htmlOpts
' .HTMLBaseFolderName = FolderName
' .HTMLFileName = "001.htm "
' .HTMLEnableSeparatedPages = True
' .HTMLHasPageNavigator = True
' '.UsePageRange = True
'End With
'exportOpts.FormatOptions = htmlOpts
' 'exportOpts.
'exportOpts.ExportFormatType = ExportFormatType.HTML40
Case 4 '生成水晶报表
If System.IO.File.Exists(fileName) Then
File.Delete(fileName)
Else
End If
exportOpts.ExportFormatType = ExportFormatType.CrystalReport
diskOpts.DiskFileName = fileName
End Select

exportOpts.DestinationOptions = diskOpts

'Report.Refresh
' 导出报表。
Dim strError As String
Try
Report.Export()
Catch err As Exception
strError = err.Message.ToString
End Try
End Sub
End Class