Rdlc Report (2)

Source: Internet
Author: User

Dizzy, always see friends comment to gotreportviewer instance, please download in the following connection:Http://files.cnblogs.com/waxdoll/RDLC.rar

In this article, I will analyze several classic examples on gotreportviewer. We can see the powerful functions of reportviewer control:

1. Web log analyzer

This is a typical OLAP application. We can see the powerful chart and navigation functions of rdlc reports. Of course, the W3C standard Log FileCodeIt is also very useful for reference. This starter kit is included in my notebook.

2. subreports

Shows how to use a subreport to display the details of a master record. This type of application is similar to the subreport function in access. The subreportprocessing event is used to provide data for subreports.

3. Drilling Reports

Drilling Reports are implemented by setting navigation (Hyperlink) and parameters.Program.

4. Drilling Reports with subreports

This example provides functions similar to the pivot table function in Excel. In a complex cross table, you can drill down the time and commodity dimensions. This may be difficult to implement in other reports .,

5. Reference external code blocks

 

This example shows how to read the function return value from another util class to the report. First, use the addtrustedcodemoduleincurrentappdomain method of localreport to allow methods in the util class to be executed in the report viewer, then, use the value node of the Textbox Control in the report to call the static method factorial in util to display the return value in the report.
Another example is basically the same. It only accesses a text file in the util class and displays the characters in the text file in the report.

6. Export to excel

Rdlc reports have very good results in exporting to excel. Once I saw another report designer (like Crystal Report) Export to an Excel file, the results were very poor, and cells were not aligned at all, users cannot perform secondary operations on the basis of this, but the Excel file exported from the rdlc report does not have this disadvantage, and the format set for the original report is basically retained .,

You can directly use the button that comes with the report viewer control to generate an Excel file, or use the following code to complete the operation:

Microsot. Reporting. winforms. Warning [] warnings;
String [] Strstreamids;
String Strmimetype;
String Strencoding;
String Strfilenameextension;

Byte [] Bytes =   This . Rptviewer. localreport. Render ( " Excel " , Null , Out Strmimetype, Out Strencoding, Out Strfilenameextension, Out Strstreamids, Out Warnings );

String Strfilepath =   @" D: \ report. Xls " ;

Using (System. Io. filestream FS =   New Filestream (strfilepath, filemode. Create ))
{
FS. Write (bytes,0, Bytes. Length );
}

The render method of localreport will be described in detail later.

7. Interactive sorting

Among the many interactive functions of the rdlc report, this function is quite novel. End users can sort data by the icons on the column titles in the report, the effect of previewing and printing depends entirely on the user's sorting. [There seems to be a bug here, that is, the preview effect after sorting the data will remain unchanged, unless this application is enabled again and re-ordered.] You do not need to perform any operations in the code. You only need to add the <usersort> section in the report definition file and specify the corresponding sortexpression and sortexpressionscope.

8. RSS news reader

How can I use reportviewer to implement an RSS news reader? Yes !,

Of course, this sample is used to demonstrate the support for Object-type data sources. The report parameter reportparameter is also used.

 

9. Main and sub-tables that can be drilled

The other is a main subreport that allows drill-down .,

10. print the report from the command line

Rdlc reports allow you to use the render method of localreport instead of using the code to control output and print directly through the reportviewer graphic interface. In the future, we will refer to this example to introduce how to customize the paper.

11. Ticket generation

In this example, you can enter a document and its details to generate a printed ticket .,

12. dynamically generate an rdlc File

This may be the most important example. The rdlc file is described in XML and can be directly generated using code, so that the report can be very flexible. For example, programs that directly preview and print data from the datagridview on the Internet can be replaced by this method. Further extension, you can implement your own rdlc-based report designer, in this way, end users can be involved in the report design, at least so that they can modify some titles and headers in the report.

Gotreportviewer also provides several other examples, such as setting report parameters and mailing reports by email. These examples are not very typical and will not be repeated.

Gotreportviwer does not know why it has recently failed. Friends who need these routines can leave an email.

Related essays:
Rdlc Report (1)

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.