Merged cells in Excel output

There is a list report with many columns. The report shows the title in page header. Users mostly access this report in Excel format.

When the output is generated, Cognos puts the output in the first cell (A1). This stretches the A column.

Merged cells in Excel output

In this recipe, we will see how to get Cognos to generate merged cells so that the columns are not stretched.

Getting ready

Create a simple list report. Put a report title in the page header.

Getting ready

How to do it...

  1. Insert a Table from the 'Insertable objects' pane into the report header.
  2. Set the Number of columns to 4. Keep Number of rows at 1. Hit OK.
    How to do it...
  3. Now select the first cell of the table. Hold down Shift key and select the last cell of the table. This should select all the cells.
  4. From the menu, select Table | Merge Cells. This will merge four cells into one.
  5. Now unlock the report objects. Select the report title and drag it inside the table.
  6. Change the text font and size appropriately.
  7. Run the report in Excel to test it. As you can see in the following screenshot, the title will now be shown in merged cells and hence the first column won't be stretched.
    How to do it...

How it works...

When we merge the cells of a table, this is remembered in the report specification in the form of column span. In our example, the report spec says <tableCell colSpan="4">. When the report runs in Excel form, this is properly translated into merged cells.

Not many developers know about this feature, but it is a very useful one. After reading this, you will use it in many real-life scenarios.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset