Use and comparison of DevExpress's Xtrareport and Microsoft RDLC reports

Source: Internet
Author: User



When we develop the program, often encounter some reports, if it is WinForm report, generally can use the DevExpress control group Xtrareport, or Microsoft's RDLC report, of course, there are some other, not repeat it here. Because I often use some reports in the development of WinForm, sometimes use Xtrareport reports, sometimes also use the RDLC report, so this article mainly introduces the use of these two different types of reports, and compare their differences, so that we better grasp the understanding.


1, the use of Xtrareport Report 1) Report interface display


In my dispatch car management system, I need to according to the database records, the relevant dispatch vehicle history information into a report statistics module, need to list the details of the report (send car details) and statistical values (record number, kilometer), this type of report is a lot of situations need to encounter.



I need to implement a functional interface based on the Xtrareport reporting technology, as shown in the following illustration.






The fields involved, including the character type, date type, numeric type, enumeration type, etc., as well as statistical values, printing time (parameters), are also counted as a more complete presentation of the report.





2) Create a new report


To implement this report module, we first create a report Component object using the VS tool.









Before use, we need to set up the various display modules of the report components, Report report the upper and lower space section (Topmargin/bottommargin), which two parts to adjust the upper and lower edges;



Then each report has a distinction between the head content and the bottom content, ReportHeader is generally used to place the table header field display, the details of which include the details of the display list, roughly adjusted as shown below.











3) Design report control and data source management


In the VS left-hand toolbox, there is a responsive xtrareport control that you can drag into the report interface to draw the design.






In order to achieve the table statistics and display, we need to drag two tables into the report interface, one is the report header field, a list to display the report details of the content, the width of the two cells are consistent, and the upper and lower space to be next to each other, otherwise displayed there is space, not good-looking.



Once the table has been dragged past, you can use the right mouse button to add the appropriate cells, and then set their background color, height width, border and other properties uniformly.



Table header We can fill in the relevant text substitution, but the details of the report, we need to bind the corresponding field content, so we need to add a data source to bind to the report up.



Inside the report properties, locate DataSource to configure as shown below.






By dragging the related table and then designing its interface, and binding the contents of the detail cell to a format such as [ABC], it identifies the field attribute bound to an ABC. The field shown below is bound to a handno.






The final design of the report interface is shown below.





4) Handling of special fields


In the design process of the report, we usually encounter a variety of different fields, it is not a simple text message, it may be a date, it can be statistical values, calculated values and so on.






Printing time, only need to add a xrpageinfo, and then set the value inside it, which is somewhat similar to the parameter values of RDLC.






From the above we can see that there are many items to choose from, in addition to the time, there are records, Total records, user name, total, and so on.



The statistical design of the number of records is shown below, mainly by means of a thousand-way display, called count function processing.






Similarly, the total number of kilometers, is the statistics of the entire report the number of kilometers recorded in the operation, call the SUM function processing, its design interface is as follows.






After the design of the Xtra report, we can be inside the program, the direct call to load processing can be, 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 get the data source, and bind the data source to the corresponding report component, and then call Reportprinttool to show, the code is very concise, but the design process is a bit cumbersome.





2, the use of the RDLC report


In my "Member Management System design and development (2)--The design of the RDLC report and dynamic Loading", there is a description of the RDLC report design, RDLC is Microsoft's report format, it is a relatively independent file, is an XML-based descriptive file, In addition to the WinForm Sisu can be used in the web, but also very good versatility.



Based on the comparison, I also designed the same report for the same module, the RDLC Report final display interface is shown below.






Make a comparison with the previous Xtrareport report interface.






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


1) The design effect of RDLC





Because RDLC is a standalone XML file, its description is all in one XML, so when we design it, we just process the XML file, VS gives us a designer and design.



In the Design view of RDLC, we can see the report data, including some predefined data, and the data source we added.






Of course, the report design is not related to the control, so in the toolbar, you can see the report control elements you can use, as shown below.





2) handling of special elements of reports


The RDLC report, which also has some such as print time, paging data, and so on, requires special processing, and the print time is using the "built-in fields" item in the report data, as shown below.






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






The operation of the total statistics is designed as follows, call the SUM function, if you forget that, you can query in the following categories, there are many operators, common functions and other content can be used.






In addition, for some special display format, we need to set the correct settings, as follows is the date formatting.








3) Call handling for reports


Due to the presentation module of the report, I have put it into a standalone generic module, so for the load of the report, simply set the property, and then call it, as shown below.



Private void PrintRDLCReport ()
{
The string where = GetConditionSql ();
A List < CarApplyInfo > List = BLLFactory < CarApply >. The Instance. The Find (where);
Foreach (CarApplyInfo info in list)
{
Info. Data1 = info. Status. The ToString (); Convert enumerated type description
}

ReportViewerDialog DLG = new ReportViewerDialog();
DLG.Text = "history report ";
DLG. DataSourceDict. Add (" CarApplyInfo ", a list);
DLG. ReportName = "WHC. CarDispatch. HistoryReport";
DLG. IsPrintLayout = true;

DLG. ShowDialog ();
} 


It is primarily a data source, specifying the report path and layout, and then binding the Report Presentation Module window.



A few system functions are attached below, for reference study.



1) main interface list, based on Gridcontrol display, and add Statistics column.






2) History Report Presentation (Xtrareport report)






3) Two different formats of the dispatch of a single report display (RDLC report).











3. Difference between Xtrareport report and RDLC paper


Both of the reports can achieve similar results, but Xtrareport is to integrate it into the DLL, like a compiled form file, and the RDLC report itself is a separate file, we publish, we want to take it, but there is a good commonality.



For xtrareport field content display, the default is to call the ToString () function processing, so similar to the date, enumeration type, do not need to how to set, it can be displayed normally, but in the RDLC report design, we need to set the corresponding format for each field, Enumeration types appear to be parsed or converted to shaping, so they need to be converted at the data source level, otherwise they are not displayed.



For custom functions, Xtrareport provides a good design interface to greatly reduce the chance of error, while RDLC provides flexible operations, provides many functions for reference, and requires you to add expressions, but at compile time, you can check for errors.



If you need to dynamically configure, load, or develop some new report presentations, it may be relatively convenient for RDLC, you can incrementally publish some reports, and then configure in the background to show, do not need to change the source code compilation.



Use and comparison of DevExpress's 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.