Essay "Use ActiveReport for. NET for report development" __.net

Source: Internet
Author: User

(i)--Start ActiveReport is an excellent report development program under. NET, although not as famous as the Crystal Report, and many people do not know it exists, it does not prevent it from doing well in. NET report development, and this article will explain step-by-step how to use it and VS2005 development. NET report.   1.          installation: You can download the latest activereport for. NET 2 from the Data Dynamics website, you can use it for free, But there is a watermark at the bottom of the generated report, but it doesn't affect the overall appearance of the report. Download it and install it directly. After installation will see the Start-Program menu in the Datadynamics directory, which includes, help, example programs and so on. 2.          First Winform report procedure. After the installation is complete, start VS2005, see the ActiveReport icon on the startup interface, create a new project after entering, and add a new file to the project, and you can see the ActiveReport file icon in the file type. Name the report file as ActiveReport1, and you will see that there is a activereport1.rpx file in the project, which is the report file. Open the file, is the report design interface, where you can see three parts, PageHeader (table header), Detail (detail), PageFooter (footer). Open the Toolbox and add a Label to the Detail section. Here's how to display the report, add a Viewer control to the Form, and if it's not in the toolbox, you can find it by configuring the toolbox. When the Viewer is finished, write the code in the Form: ActiveReports1 rpt = new ActiveReports1 ();         rpt. Run ();     this.viewer1.Document = rpt. Document; Then F5 runs, and you can see the report displayed in the Viewer control. Note that the project name should not be named ActiveReport, otherwise you will be prompted not to find ActiverEPORT.RPX files. 3.        first Web Reporting program. Web mode of report development and WinForm, the difference is that the web needs to make some configuration, the configuration process is no longer tired, you can search in the Help "Manually Configuring Web Samples", follow the steps to configure IIS. Note that if you are using VS2005, you can run without configuration, as long as the file location option is set to file system when you create the WEB project. Also note that in the Web mode, you need to add the following paragraph in the Web.config file: < httphandlers > < add verb = "*" path= "*.rpx" type= "datadynamics.active" Reports.Web.Handlers.RpxHandler, Activereports.web, version=4.2.1.1238, Culture=neutral, publickeytoken= Cc4967777c49a3ff "/> < add verb =" * "path=" *. ActiveReport "Type=" DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler, Activereports.web, version= 4.2.1.1238, culture=neutral, publickeytoken=cc4967777c49a3ff "/> < add verb =" * "path=" *. Arcacheitem "Type=" DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessHandler, Activereports.web, version= 4.2.1.1238, culture=neutral, publickeytoken=cc4967777c49a3ff "/>
Next time we'll show you how to load and display data on a report(ii)--binding data sources In the previous essay, I wrote a simple example of using activereport for. NET, which demonstrates how to bind a data source   1 in ActiveReport.        First build a table chartingtable, with two fields, Onlineusercount, Project, create a DataSet through the wizard, and drag and drop into TableAdapter. 2.        Next, design the display format in Report Designer, placing two labels in the PageHeader, "project" and "online number" respectively. Then in the Detail area mode two corresponding label, respectively set datafiled for Project and Onlineusercount, at run time will see that these two labels show the contents of the corresponding fields. 3.        You can assign a dataset or DataView to a report as a data source, and the following shows a data source for a report: using Dataset:this. Chartingtableta Bleadapter.fill (this.dataSet1.ChartingTable); Rpt. DataSource = This.dataset1; Rpt. DataMember = This.dataSet1.ChartingTable.TableName; Rpt. Run (); this. Viewer1. Document = rpt. Document; Use Dataview:this. Chartingtabletableadapter.fill (this.dataSet1.ChartingTable); DataView dv = This.dataSet1.ChartingTable.DefaultView;; Rpt. DataSource = DV; Dv. RowFilter = "Project = ' 1 '"; Rpt. Run (); this. Viewer1. Document = rpt. Document; 4.          We can also specify a data source for a report through Report Designer. In the head of the Detail section of Report Designer, there is a small icon with a database, click on it and then appear the wizard, follow the wizard to connect to the database step-by-step, and define the query.   It shows that using a dataset as a data source is binding, but the actual project often uses a collection of objects as a data source, and next time we'll show how to display data from a collection of objects on a report.     (iii)-Displays the data   in the collection of objects; Some sample code will continue to demonstrate how to bind the collection of objects and how to extract the data from the object collection or list. 1.        Direct binding: We can define a Collection ourselves, inherit from IList, and make each of these objects an entity, for example: Customer and Customercollection. Then give the ActiveReport report DataSource directly assigned to the Customercollection instance is ok. This binding method has a complete demo in the example ActiveReport for. Net. 2.        manually load data for display objects: Two events are used here: Datainitialize and Fetchdata. Datainitialize is used to define field lists, get data, and so on, fetchdata to specify the values for each field. We simply define a customer class public class customer         {     & nbsp;          public int ID;                 public string Name;                 public string address;     then define a Customer array for the report to hold the data to display, such as public customer[] customers; You also need a value to hold the index of the current record: private int index = 0; Next, define the report in Datainitialize withThose fields: this. Fields.Add ("Name");     this. Fields.Add ("Address"); Then add the following code to the Fetchdata event: if (This.index >= this.customers.Length)         {                 eargs.eof = true;                 return;        }         Else          {                 eargs.eof = false;        }         this. fields["Name"]. Value = Customers[this.index]. Name;         this. fields["Address"]. Value = Customers[this.index]. address;     This.index + 1; The meaning of this code is to assign the Name and address property values of each customer instance in the customer array to the report'sThe Name and address fields. The first if branch in the code is to determine if the last data has been loaded, and if so, set eargs.eof to Ture and return, otherwise continue loading the next data. Then we can put the data to be displayed in the Customers array and start the display report: Customer [] Customers = new customer[2];         customer C = new Customer ();         c.name = "James";         c.address = "NOLJADFALLSJF";         Customer C2 = new Customer ();         C2. Name = "Joe";         C2. Address = "ADFAAFADF";         customers[0] = c;         customers[1] = C2;                                  rpt.customers = customers;         rpt. Run ();     This.viewer1.DocUment = rpt. Document;   Through the above example, you can see that the second approach, though cumbersome, requires programmers to handle a lot of things themselves, but it is very important for programmers to have complete control, especially when they need to do a lot of complex processing of the extracted data.   In the next essay, you will show how to use subreports to display master and subordinate tables.    (iv)-Display of master and slave tablesThe previous essay demonstrates the ActiveReport for. net</

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.