[]
Cross-tab reports group data in two dimensions (down and across). They are useful for summarizing large amounts of data in a format that cross-references information.
The following steps create a cross-tab report in the report created in FlexReport Quick Start.
Add a Button to the Form in the FlexReport Quick Start project.
Set the Button Name to 'crossC1Button' and Text to 'View Cross Tab-Report'.
Create Click event as crossC1Button_Click.
Write the following code.
Private grp2 As Group
Private Sub crossC1Button_Click(sender As Object, e As EventArgs)
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
Dim isc As 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)
Dim f1 As 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)
Dim f7 As 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)
Dim f8 As 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)
Dim f9 As 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)
Dim f10 As 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)
Dim f11 As 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()
End Sub
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();
}
Run the project. Click 'View Cross Tab-Report' button to view cross-tab report. Observe that the details corresponding to the employee titles in the two countries are shown.