1. PDF (Portable Document Format)
2. DOC (MS Word Document)
3. XLS (MS Excel Spreadsheet)
4. HTML (Hyper Text Markup Language – 3.2 or 4.0 compliant)
5. RTF (Rich Text Format)
使用Pull模式导出报表
当导出使用Pull模式创建的文件时,水晶报表准确地打开所需要的数据,下面是执行导出功能的代码:
C#代码:
VB.Net代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myReport As CrystalReport1 = New CrystalReport1()
''注意:这里我们建立一个strong-typed的水晶报表实例。
Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
myReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
'' 导出成为其它文件时也需要这个选项
'' 如Microsoft Exchange, MAPI等.
myReport.ExportOptions.ExportFormatType = CrystalDecisions. [Shared].ExportFormatType.PortableDocFormat
''这里我们导出成为.pdf格式文件,你也能选择上面的其它类型文件
DiskOpts.DiskFileName = "c:\Output.pdf"
''如果你不指定确切的目录,那么文件就会保存到[Windows]\System32目录中去了
myReport.ExportOptions.DestinationOptions = DiskOpts
''水晶报表文件不包含直接的FileName属性,因此你不能直接指定保存的文件名
''所以你不得不使用DiskFileDestinationOptions对象,设置它的DiskFileName属性
''为你想要的路径,最后将水晶报表的DestinationsOptions属性指定为上面的DiskFileDestinationOption
myReport.Export()
''上面的代码将完成导出工作。
End Sub
使用PUSH模式导出水晶报表
当导出的报表是由PUSH模式建立的时,第一步就是通过编程建立连接并组装DataSet,设置报表的的SetDataSource属性。再下面的步骤就有Pull模式一样的了。