1、代碼下載:http://support.crystaldecisions.com/communityCS/FilesAndUpdates/vbnet_win_simplepreviewreport.exe.asp?recDnlReq=Record&dnlPath=vbnet_win_simplepreviewreport.exe
2、用作 viewer.reportsource 的5種類型的報表:
- 使用 Report 名 (通過文本路徑)
- 使用 Report 對象 (通過文本路徑)
- 使用非類型的 Report 組件 (通過文本路徑和 ReportDocument reportdocument1)
- 使用 Report 對象 (通過已添加到項目的報表檔案,如:World Sales Report.rpt)
- 使用強型別的 Report 組件()(通過 ReportDocument world_Sales_Report1)
註:Report 組件即“工具箱”-〉“組件”-〉“ReportDocument”
3、代碼簡介:
- 使用 Report 名 (通過文本路徑)
CrystalReportViewer1.ReportSource = "C:/Crystal/crnet/vbnet_win_simplepreviewreport/World Sales Report.rpt"
'--------------------------------------------------------------------
- 使用 Report 對象 (通過文本路徑)
Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
crReportDocument.Load("C:/Crystal/crnet/vbnet_win_simplepreviewreport/World Sales Report.rpt")
CrystalReportViewer1.ReportSource = crReportDocument
'--------------------------------------------------------------------
- 使用非類型的 Report 組件 (通過文本路徑和 ReportDocument reportdocument1)
Dim reportdocument1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
reportdocument1.Load("C:/Crystal/crnet/vbnet_win_simplepreviewreport/World Sales Report.rpt")
CrystalReportViewer1.ReportSource = reportdocument1
'--------------------------------------------------------------------
- 使用 Report 對象 (通過已添加到項目的報表檔案,如:World Sales Report.rpt)
CrystalReportViewer1.ReportSource = New World_Sales_Report()
'--------------------------------------------------------------------
- 使用強型別的 Report 組件()(通過 ReportDocument world_Sales_Report1)
CrystalReportViewer1.ReportSource = world_Sales_Report1