Report XtraReport creation is implemented

1. Create XtraReport report program

  Generally, this program is designed separately. For convenience, I combine them together.

    First create a Winform Application, put a button in form1, right-click the program, and add a new item. As shown in the figure below, select devExpressV16.2ReportWizard. Click Add and select Empty Report in the pop-up dialog box.

 

2. Add a few Xlabels in the design view, add a ReportHeader ReportFooter, and add some content as shown in the figure

3. Click on the blue corner in the upper left corner of the designer and save it to a location, so that we can call it later

4. Well, you can call it with the template, add a DocumentViewer to Form1 to create a clik event for the button

1   private  void button1_Click( object sender, EventArgs e)
 2          {
 3              // The first implementation 
4              XtraReport1 report = new XtraReport1(); // Instantiation
 5              // Load template 
6              report.LoadLayout( @" D:\C# Exercise \WindowsFormsApplication3\WindowsFormsApplication3\XtraReport1.repx " );
 7              // false is portrait, true is landscape 
8              report.Landscape = false ;
 9              // binding data source
 10              //report.DataSource = new DataTable(); // There is no data source in my report, so it is not bound
 11              // Specify document source 
12              documentViewer1.DocumentSource = report;
 13              report.CreateDocument(); // Create document 
14             

Of course, you can directly call the original class instantiation without the template

1  // instantiate this report 
2              XtraReport1 frx = new XtraReport1();
 3              // portrait 
4              frx.Landscape = false ;
 5              // document view source = the report we created 
6              documentViewer1. DocumentSource = frx;
 7              // display the document 
8              frx.CreateDocument();

Both effects are the same

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325115161&siteId=291194637