Some time ago, the company needed to establish an online survey and voting system to count the company's capability level index. The statistical capability level was divided into three categories: Level 1 capability elements and level 2 capability elements, level-3 capacity elements: different level-1 capacity elements are divided into several level-2 capacity elements, and each level-2 capacity element is divided into many level-3 capacity elements, the result is a complex operation based on the three-level capability elements to form the value of the second-level capability element, then, statistics are made based on the obtained Level-2 capability element value and the different levels and positions of the voting personnel (the specific statistics are not detailed ), then, all the results are displayed in a bar chart. The administrator needs to export the chart information of each result.
The first idea was to use the proessencontrol, mainly because I used the control for projects in Japan some time ago and was specified to use it. I checked a circle of information, but found that in China, it seems that few people have used it, but it is still done in the end, but on winform, not on the web, tried several times, failed, and administrative rush, so I am so brave to use the legendary Crystal Report that I have never used ).
Because I have never been in touch with it, let alone use it. Although I have never worked on web charts, my accumulated self-confidence in the face of problems makes me feel like a small CASE, the result is really a small CASE.
So many things have been involved, and now we are turning to the subject.
Crystal Report is a Chart partner of Microsoft. It is excellent because it is professional, although Microsoft has (Microsoft Chart ), however, the crystal report is attached to Visual Studio 2005 as a built-in control.
The crystal report includes two modes: Pull Mode and Push mode. The following describes the differences between the two modes.
The Pull mode is a mode that pulls data directly from the database. Therefore, the Pull mode is called Pull. The Pull mode is mainly used to establish a connection with the database, pull the data from the database and display it on the report. the benefit of the Pull mode is that you can read report data and create reports without writing a line of code.
Compared with the pull mode, the Push mode is a relatively advanced mode. The data obtained by the Push mode needs to be obtained using ADO. NET to obtain the data, and then display it on the report. the Push mode can achieve custom data acquisition, which maximizes feature customization. However, you need to write a certain degree of code (that is, to obtain data ).
In general, the Pull mode and the Push mode are different in obtaining data. No matter which method is used, after obtaining the data, you only need to associate the obtained data with the crystal report.
The following describes how to obtain data in two modes:
I. pull Mode
First, drag the CrystalReportSource control and CrystalReportViewer control from the crystal report Toolbar of the Toolbox. the CrystalReportSource control has similar functions as other data source controls, that is, to establish a connection with the prepared reports. the CrystalReportViewer control is used to display the Crystal Report on the WEB. Its main function is to establish a contact with CrystalReportSource, which has been established with the crystal report, so that users can view the Crystal Report on the WEB, therefore, CrystalReportViewer is also called a crystal report viewer. None of the two are displayed normally in Pull mode. crystalReportSource needs to specify a crystal report file. If there is no crystal report available, you can create a new crystal report through the CrystalReportSource wizard. During the creation process, it is specified as a blank report, after the report is created, a field resource manager is displayed on the left. Right-click the database field and select a database expert. A dialog box for database experts is displayed, select the ole db (ADO) option in creating a new connection. Because I use the SQL server 2005 database, select SQL Native Client in the pop-up data source configuration and click Next, enter the server name, user name, password, and database in sequence. Click OK and you will find all the fields in the database appear in the left-side database field, the data connection in such a Pull mode is successful, and then a specific crystal report is created based on the style of the crystal report we need (how can we write another article here). The following prompt is displayed, to display the information in the database, you only need to drag the field to the Crystal Report. finally, specify the data source of CrystalReportViewer as the configured CrystalReportSource. basically, the establishment of a Pull crystal report is complete.
Ii. push mode
The Push mode mainly displays custom data. First, you need to create a DataSet in the project. The specific method is to add a DataSet in the project, the specific method is to right-click the root directory of the project in the resource manager, select Add new item, select the dataset, and name it MyDataSet. XSD: There are two ways to fill the data after the dataset is created. The first is to drag the relevant data fields from the server resource manager to the data set, and the second is to create the fields in the dataset, when the data is filled in, you can use ADO. NET to implement data filling, but the filled DataSet is our own defined MyDataSet. In fact, there are many tables and fields we can customize according to our needs in the MyDataSet we fill in, in this way, we can achieve the maximization of Data customization. After the data is filled, it is about the configuration of the crystal report data source. In the Push mode, right-click the database field in the resource manager of the Crystal Report field, and select ADO under the project data.. NET dataset. then we can clearly see In ADO. the. NET dataset contains our custom MyDataSet dataset. Select the custom table under the custom dataset and add the table to the column on the right, in this way, we can use related fields to create a crystal report like the Pull mode.
The above are the differences between the two modes and the specific practices.
Next we will talk about some of the problems encountered.
The number of times of use. as a professional commercial chart, Crystal reports cannot be used for free. When Visual Studio 2005 is installed, the built-in Crystal Reports can only be used for 30 times, that is, you are using ASP. NET Development Server can only be used for 30 times for debugging. If you want to continue using it, stop ASP. NET Development Server and need to be regenerated. Similarly, for iis deployed and installed. the same is true for deployment projects of net framework 2.0. They can only be used for thirty times. What should I do? Good, open the registry, find the HKEY-LOCAL-MACHINE-> Crystal Decisions-> 10.2-> Report Application Server-> the key under InProServer PrintJobLimit and change the value to 1000, then find the HKEY-LOCAL-MACHINE-> Crystal Decisions-> 10.2-> Report Application Server-> the key PrintJobLimit under the Server and also change the value to 1000, so that you can fully meet your requirements to pull.
Then there is the deployment problem, because it is not deployed on the local machine, but on other machines, and the deployed machine is installed with Visual Studio 2005, but there is a problem, after deployment, the crystal report charts are invisible, and some printing and export functions cannot be used. the solution is to find the aspnet_client folder on the deployment machine and copy the folder to the folder of the publishing website. OK, everything is done!
To sum up the use of the crystal report, it is very convenient to use the crystal report, and there is strong support for related charts. for developers, it can greatly reduce the time required for development. the above is just a brief introduction of some experience on the use of Crystal Reports. If you have any questions, please feel free to contact me. Welcome to discuss it! The following is an attachment!