Related articles:
Crystal report encapsulated into VB DLL
Crystal Report (Crystal) is the industry's most professional and powerful reporting system, in addition to the powerful report function, the biggest advantage is to achieve with the vast majority of popular development tools integration and interface. In the Vs.net platform has done the report development programmer, must have the Crystal report strong, high efficiency, the integration and so on the characteristic has left the deep impression. In addition to the development of new programs, in the work we often need to contact many of the earlier software system report function upgrade requirements, if the combination of Crystal Report this powerful tool, often can be more than twice.
VB is the previous popular database development platform, with its development of C/s system in the community has a very large amount of, but the VB Super weak report function often let programmers face the customer's upgrade requirements helpless. This article does not do the use of Crystal Report and programming teaching, in fact, the Crystal report itself using methods and vs.net platform is not too much difference, I am mainly and you discuss VB and Crystal Report a more convenient interface. My development test platform is Windows2003 standard Simplified Chinese version, VB6.0+SP5 English version, Crystal 9.0 Simplified Chinese development version.
The method of making report template in Crystal Report is not the scope of this article, the reader can refer to the Help file of crystal and the technical data of the official website. Simple to say, first of all, through the Crystal Report database engine to manually connect the corresponding table structure, make the report template, and Save as RPT file, the operation and use of VB from the report tools produced a similar report.
Simply put, using VB to call the Crystal Report Report development of the Simple interface method is, in the Crystal Report with "field definition only" to get the field distribution file, using virtual files to create table fields, Using the CRAXDRT object to force the change of the data source (ado.recordset), the effect is equivalent to calling the Rpt file in VB. The following step-by-step describes the programming method.
First step:
In the VB Project menu to add "Add Crystal Report 9", the name is used by default. The Form2 (Crystal rerport automatically added form, assuming the name Form2) is automatically assigned the following code:
Option Explicit
dim Report as New Cystal1
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
'调用水晶报表时置鼠标为沙漏状 CRViewer91.ReportSource = Report '该语句的赋值将在后面被修改
CRViewer91.ViewReport
Screen.MousePointer = vbDefault '调用水晶报表完成后置鼠标为默认形状
End Sub
Private Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
Step Two:
Click Database field in Crystal, select Database Expert ..., and then click Create New connection, click Field Definition only, and create a database definition file with the field name and width consistent with the original database table. Finally, in the database field to obtain the corresponding field, put it on the report, according to the requirements of the Crystal Report configuration.