Page tree
Skip to end of metadata
Go to start of metadata


交叉表报表以两个维度(向下和横向)分组数据。它们对于以交叉引用信息的格式汇总大量数据很有用。

以下步骤对FlexReport快速入门中创建的报表来创建交叉表 。 

  1. 在FlexReport快速入门项目的表单中添加一个按钮
  2. 将按钮名称设置为'crossC1Button',将文本设置为'显示交叉表'。
  3. Click事件创建为crossC1Button_Click
  4. 编写以下代码。

    CS
    Group grp2;
            private void crossC1Button_Click(object sender, EventArgs e)
            {
               
        btnEmployees.PerformClick();
        c1FlexReport1.Sections.Detail.Visible = false;
              
        grp2 = c1FlexReport1.Groups.Add("GrpCountry", "Country", SortEnum.Ascending);
                // format the Header section for the new group       
        c1FlexReport1.Sections.PageHeader.Height = 600;
        shpfld2.Top = 600;
        s = grp2.SectionHeader;
        s.Height = 400;
        s.AutoHeight = AutoSizeBehavior.GrowAndShrink;
        s.Visible = true;
        textFld4.Text = "Country";
        textFld4.Width = 1000;
        textFld4.Align = FieldAlignEnum.CenterMiddle;
        textFld4.Height = 400;          
        textFld4.Font.Bold = true;
        textFld4.Font.Size = 10;
        textFld5.Text = "Total";
        textFld5.Width = 1000;
        textFld5.Left = 1000;
        textFld5.Align = FieldAlignEnum.CenterMiddle;
        textFld5.Height = 400;
        textFld5.Font.Bold = true;
        textFld5.Font.Size = 10;
        textFld6.Text = "Sales Representative";
        textFld6.Width = 2000;
        textFld6.Left = 2000;
        textFld6.Align = FieldAlignEnum.CenterMiddle;
        textFld6.Height = 500;
        textFld6.Font.Bold = true;
        textFld6.Font.Size = 10;
        textFld7.Text = "Vice President";
        textFld7.Width = 1500;
        textFld7.Left = 4000;
        textFld7.Align = FieldAlignEnum.CenterMiddle;
        textFld7.Height = 400;
        textFld7.Font.Bold = true;
        textFld7.Font.Size = 10;
        textFld8.Text = "Sales Manager";
        textFld8.Width = 1500;
        textFld8.Left = 5800;
        textFld8.Align = FieldAlignEnum.CenterMiddle;
        textFld8.Height = 400;
        textFld8.Font.Bold = true;
        textFld8.Font.Size = 10;
        TextField isc = new TextField();
         isc.Text = "Inside Sales Coordinator";
         isc.Width = 1500;
         isc.Left = 7500;
         isc.Align = FieldAlignEnum.CenterMiddle;
         isc.Height = 400;
         isc.Font.Bold = true;
         isc.Font.Size = 10;
         isc.Visible = true;
         c1FlexReport1.Sections.PageHeader.Fields.Add(isc);
         Field f1 = new Field();
         f1.Name = "Country";
         f1.Text = "Country";
         f1.Left = 80;
         f1.Top = 0;
         f1.Width = 1000;
         f1.Height = 400;
         f1.Align = FieldAlignEnum.CenterMiddle;
         f1.MarginLeft = 100;
         f1.Calculated = true;
         f1.Visible = true;
         f1.BackColor = Color.Transparent;
         f1.Font.Bold = true;
         f1.Font.Size = 10;
         s.Fields.Add(f1);
         TextField f7 = new TextField();
         f7.Name = "RunCount";           
         f7.Text = "=Count(Title)";
         f7.Left = 1080;
         f7.Top = 0;
         f7.Width = 1000;
         f7.Height = 400;
         f7.Align = FieldAlignEnum.CenterMiddle;
         f7.MarginLeft = 100;
         f7.Visible = true;
         f7.Font.Bold = true;
         f7.Font.Size = 10;
         s.Fields.Add(f7);
         TextField f8 = new TextField();
         f8.Name = "SRCount";
         f8.Text = "=Count(Title, Title = \"Sales Representative\")";
         f8.Left = 2080;
         f8.Top = 0;
         f8.Width = 1000;
         f8.Height = 400;
         f8.Align = FieldAlignEnum.CenterMiddle;
         f8.MarginLeft = 100;
         f8.Visible = true;
         f8.Font.Bold = true;
         f8.Font.Size = 10;
         s.Fields.Add(f8);
         TextField f9 = new TextField();
         f9.Name = "VPCount";
         f9.Text = "=Count(Title, Title = \"Vice President, Sales\")";
         f9.Left = 4000;
         f9.Top = 0;
         f9.Width = 1000;
         f9.Height = 400;
         f9.Align = FieldAlignEnum.CenterMiddle;
         f9.MarginLeft = 100;
         f9.Visible = true;
         f9.Font.Bold = true;
         f9.Font.Size = 10;
         s.Fields.Add(f9);
         TextField f10 = new TextField();
         f10.Name = "SMCount";
         f10.Text = "=Count(Title, Title = \"Sales Manager\")";
         f10.Left = 5800;
         f10.Top = 0;
         f10.Width = 1000;
         f10.Height = 400;
         f10.Align = FieldAlignEnum.CenterMiddle;
         f10.MarginLeft = 100;
         f10.Visible = true;
         f10.Font.Bold = true;
         f10.Font.Size = 10;
         s.Fields.Add(f10);
         TextField f11 = new TextField();
         f11.Name = "ISCCount";
         f11.Text = "=Count(Title, Title = \"Inside Sales Coordinator\")";
         f11.Left = 7500;
         f11.Top = 0;
         f11.Width = 1000;
         f11.Height = 400;
         f11.Align = FieldAlignEnum.CenterMiddle;
         f11.MarginLeft = 100;
         f11.Visible = true;
         f11.Font.Bold = true;
         f11.Font.Size = 10;
         s.Fields.Add(f11);            
         c1FlexReport1.Render();
         }
  1. 运行项目。单击“显示交叉表”按钮以查看交叉表报表。请注意,报表显示了与两个国家中的雇员职位相对应的详细信息。纵向按照国家统计,横向按照职位统计

    跨标签报告

 

  • No labels