程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> vb / C# 中報表套打的輕松實現

vb / C# 中報表套打的輕松實現

編輯:.NET實例教程
關鍵字: vb c# 報表 套打

微軟的crystal report是非常不錯的報表工具,今天我想和大家聊聊如果在vb 60 中使用crystal report 提供的環境在vb 中請輕松實現報表的套打功能。以水晶報表9為用例

craxddrt9.dll

craxddrt9_res_chs.dll

CRDesignerCtrl.DLL

crdesignerctrl_res_chs.dll

以上四個dll在你安裝好水晶9後會存在你系統環境中。你可以在vb項目中通過浏覽文件直接引用這幾個dll

,或則在引用checkbox 列表中選 "reystal reports 9 activex Designer run time library",""

"reystal reports 9 activex Designer Design and runtime library"

然後再工具箱添加一個 compernent 選"Embeddedle crystal report 9 designer Control"

添加後工具箱多了一個CRDesignerCtrl

ok 環境有了,然後我們可以把crystal report 的設計界面嵌入到我們的vb程序了。

程序效果如下:



design



簡述一下如何將一個rpt文件打開成設計界面

代碼如下

[vb 6]

Private Sub Command1_Click()
Dim f_Name As String
Dim m_Application As New CRAXDDRT.Application
Dim m_Report As New CRAXDDRT.Report

reportPath = ""
Me.CommonDialog1.ShowOpen
reportPath = Me.CommonDialog1.FileName
If reportPath <> "" Then
Set m_Report = m_Application.OpenReport(reportPath, 0)
Me.CRDesignerCtrl1.ReportObject = m_Report
End If
End Sub

CRDesignerCtrl1為前面我們添加的報表設計控件。

[c#]

CRAXDDRT.Application m_Application = new CRAXDDRT.ApplicationClass();
CRAXDDRT.Report m_Report;
this.openFileDialog1.ShowDialog();
f_Name=this.openFileDialog1.FileName.ToString();

m_Report=m_Application.OpenReport(f_Name,0);
this.axCRDesignerCtrl1.ReportObject=m_Report;
this.axCRDesignerCtrl1.DisplayFieldVIEw=false;

#結束
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved