Printing complex headers

Top  Previous  Next

Here we are talking about headers which contain spanned cells. When printing rows or columns of the table, which has got spanned cells, the cells automatically increase in size. We will show this in the next example:

 

tableExample8

 

We will create a ManualBuild event handler, which will be printing the first column 3 times and the second column 1 time:

 

private void Table1_ManualBuild(object sender, EventArgs e)

{

  // printing row 1 and columns 0, 0, 0, 1

  Table1.PrintRow(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(1);

 

  // printing row 1 and columns 0, 0, 0, 1

  Table1.PrintRow(1);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(1);

}

 

Pay attention that we have printed the same number of columns in every row. If this rule is violated, then we will get an unpredictable result.

 

As a result of executing this code, we will get the following:

 

tableExample8Result

 

As seen, the header cell is spanned automatically. We will make the code a little more complex, so that two groups of columns can be printed:

 

private void Table1_ManualBuild(object sender, EventArgs e)

{

  // print 0 row and two groups of 0, 0, 0, 1 columns

  Table1.PrintRow(0);

  // group 1

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(1);

  // group 2

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(1);

  

  // print 1 row and two groups of 0, 0, 0, 1 columns

  Table1.PrintRow(1);

  // group 1

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(1);

  // group 2

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(0);

  Table1.PrintColumn(1);

}

 

When we run the report, we will see the following result:

 

tableExample8Result1

 

When printing the second column with the following code:

 

Table1.PrintColumn(1);

 

the header is finished and further printing of the first column starts a new header:

 

// group 2

Table1.PrintColumn(0);