Use and comparison of devexpress xtrareport and Microsoft rdlc reports

Source: Internet
Author: User
Original article: Use and comparison of devexpress xtrareport and Microsoft rdlc reports

When developing programs, we often encounter some reports. For winform reports, we can generally use xtrareport in the devexpress control group or Microsoft rdlc reports. Of course there are some other reports, I will not go into details here. As I often use some reports in winform development, sometimes xtrareport reports and rdlc reports are used, this article mainly introduces the use of these two types of reports, and compare their differences so that we can better understand them.

1. Use of xtrareport Report 1) report interface display

In my dispatch management system, I need to make relevant dispatch history information into a report statistics module based on the database record, and list the details of the report (dispatch details) and statistical value (number of records, number of kilometers), this type of report is often encountered.

I need to implement a functional interface based on the xtrareport report technology, as shown in the following figure.

 

The fields involved here include numeric, date, numeric, and enumeration types, statistical values, and printing time (parameters). Therefore, a complete report is displayed.

 

2) create a new report

To implement this report module, we first use the vs tool to create a report component object.

 

Before use, we need to set the display modules of the report component. The upper and lower spaces of the report (topmargin/bottommargin) are used to adjust the upper and lower edges;

Then, each report has a distinction between the header content and the bottom content. reportheader is generally used to place the table header field for display. The detailed content includes the detailed information of the display list, which is roughly adjusted as follows.

 

3) Design Report controls and data source management

In the Toolbox on the left of Vs, there is a response xtrareport control. Drag it to the report interface to design the xtrareport.

To achieve table statistics and display, we need to drag two tables to the report interface. One is the report header field and the other is the list content used to display the report details. The two cells have the same width settings, in addition, the upper and lower spaces need to be placed in the upper and lower spaces. Otherwise, space is displayed, which is hard to see.

After dragging a table, you can right-click it to add the corresponding cells, and set the background color, height width, border, and other attributes.

The table header can be replaced by related text. However, for detailed report information, we need to bind the corresponding field content. Therefore, we need to add a data source to bind it to the report.

In report properties, locate datasource for configuration, as shown below.

Drag the relevant table, design its interface, and bind the content of the detail cell to a format like [ABC]. Then, the field attribute of ABC is bound. As shown below, a handno field is bound to display.

The final design report interface is as follows.

4) Processing of special fields

During the design of a report, we generally encounter different fields, which are not simple text information, may be dates, statistical values, and calculation values.

Print time. You only need to add an xrpageinfo and set the value in it. This is a bit similar to the rdlc parameter value.

From the above we can see that there are many projects to choose from, in addition to time, as well as the number of records, the total number of records, user names, the total number and so on.

The statistical design of the number of records is as follows. It is mainly displayed in the kilobytes and processed by calling the count function.

Similarly, the total number of kilometers is to count the number of kilometers recorded in the entire report. It calls the sum function for processing. Its design interface is as follows.

 

After the Xtra report is designed, you can directly call the program to load the report. The Code is as follows.

        private void PrintReport()        {            string where = GetConditionSql();            List<CarApplyInfo> list = BLLFactory<CarApply>.Instance.Find(where);            FrmHistoryReport report = new FrmHistoryReport();            report.DataSource = list;            ReportPrintTool tool = new ReportPrintTool(report);            tool.ShowPreview();        }

We mainly obtain the data source, bind the data source to the corresponding report component, and then call reportprinttool for presentation. The code is very concise, but the design process is troublesome.

 

2. Use of rdlc reports

In my member management system design and development (2) -- rdlc report design and dynamic loading, I have introduced the rdlc report design, rdlc is a Microsoft report format. It is a relatively independent file. It is an XML-based descriptive file. It can be used on both winform and web, versatility is also very good.

Based on the comparison, I also designed a report for the same module. The final presentation interface of the rdlc report is as follows.

Compared with the previous report interface of xtrareport.

The two display effects are similar, but there are some differences in the interface effects.

1) design effect of rdlc

Since rdlc is an independent XML file, its description is all in one XML file. Therefore, when we design it, we only process the XML file, vs provides us with a designer and a design.

In the rdlc design view, we can see the report data, including some pre-defined data and the data sources we added.

Of course, the report design requires related controls. Therefore, you can see the following report control elements in the toolbar.

2) handling of special elements in reports

Rdlc reports, such as printing time and paging data, require special processing. The printing time is a [Built-in Field] project in the report data, as shown below.

 

For the total number of records and statistical values, we can process them in a custom format, as shown below.

The operation for counting the total number is designed as follows. You can call the sum function. If you forget it, You can query it in the following categories. There are many operators and common functions that can be used.

In addition, for some special display formats, we need to set them correctly, as follows.

 

3) report call processing

As the report presentation module has been placed in an independent general module, you only need to set attributes for report loading and then call it, as shown below.

Private void printrdlcreport () {string where = getconditionsql (); List <carapplyinfo> List = bllfactory <carapply>. instance. find (where); foreach (carapplyinfo info in list) {info. data1 = info. status. tostring (); // conversion Enumeration type description} reportviewerdialog DLG = new reportviewerdialog (); DLG. TEXT = "history report"; DLG. datasourcedict. add ("carapplyinfo", list); DLG. reportname = "WHC. cardispatch. historyreport "; DLG. isprintlayout = true; DLG. showdialog ();}

The preceding section mainly describes how to build a data source, specify the report path and layout, and then bind the report Presentation Module window.

The following are some system functions for your reference.

1) the main interface list is displayed based on gridcontrol and a statistical column is added.

2) history report Presentation (xtrareport Report)

3) Two report formats (rdlc report ).

 

3. Differences between xtrareport report and rdlc report

Both reports can achieve similar results, but xtrareport integrates it into the DLL, similar to the compiled form file. The rdlc report itself is an independent file, we should take it with us when releasing it, but it has good versatility.

For the display of xtrareport field content, the tostring () function is called by default. Therefore, it can be displayed normally without any settings similar to date or enumeration type, however, in the rdlc report design, we need to set the corresponding format for each field. The Enumeration type seems to be parsed and converted to an integer, so we need to convert it at the data source level. Otherwise, it cannot be displayed.

In terms of user-defined functions, xtrareport provides a good design interface that can greatly reduce the chance of errors. rdlc provides flexible operations and provides reference for many functions, you need to add expressions by yourself, but you can check the errors during compilation.

If you need to dynamically configure, load, or develop some new report presentations, rdlc may be more convenient. You can incrementally publish some reports and then configure them in the background for presentation, source code compilation does not need to be modified.

 

Use and comparison of devexpress xtrareport and Microsoft rdlc reports

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.