Welcome to MSDN Blogs Sign in | Join | Help

Services Rendered

An Insider's Look into the World of SQL Server Reporting Services Report Rendering
Merge Ahead

One issue that continually vexes users of the SQL Server Reporting Services Excel rendering extension is that of merged cells in the Excel output.  Merged cells can be a problem because Excel's sort functionality is very particular about the way cells have to be merged in order to work properly.  Excel requires that ranges of merged cells be identically sized in order to be sorted.

So, why does the renderer merge cells?  It's important to keep in mind that the Excel renderer is primarily a layout renderer.  Its goal in life is to replicate your defined report layout as closely as possible as an Excel workbook.  At that task, it does a really good job.  A consequence of this design goal is that in striving to preserve the layout, cells need to be merged on the worksheet surface.

Consider this example.  This is a very common case that I see a lot of users running into.  Say you have a report with a single Table and a Textbox above it acting as a header that is laid out like this:

When rendering to Excel, in order to preserve the layout defined above (in particular, the dimensions of each Textbox relative to one another), the worksheet cell grid is configured like this:

If you want to sort the Table data in Excel you cannnot because the first Table column consists of merged columns A and B and the second is column C.  Excel's sort function cannot handle this case.

If exporting to Excel with the ability to sort is important to you, here are some tips to help you reduce the amount of merged cells in your workbooks:

  1. Make sure the left and right edges of all report items line up with one another.  This is the #1 cause of merged cells.  Referring to the example above, if the header Textbox's left and right edges lined up precisely with the width of the first table column, the merge would not be necessary.  This technique should solve this problem for the majority of cases.
  2. Even if you do line up everyting precisely, you may find in some rare cases that there are still some columns merged.  This could be due to internal rounding and unit conversion issues when we lay out the Excel worksheet at render time.  Report Definition Language allows you to specify position and size values in a number of different measurement units such as inches, pixels, centimeters, and points.  But, internally the Excel format wants everything to be in points.  To minimize the amount of conversion that we have to do at render-time to change your inches and centimeters to points, consider specifying all of your measurments in points for the most direct results.  One inch is 72 points.  This is a much rarer case, so consider following this step if the technique described in #1 still does not solve your problem.  This will be substantially improved in the next version of Reporting Services.
  3. Use the third-party report design and rendering tool SoftArtisans OfficeWriter.  Using OfficeWriter, reports are designed using Excel as the authoring tool and the Excel document itself becomes the report layout definition.  Because you are both designing and delivering in Excel, you can achieve precise Excel layout.

I hope this helps clear up some of the questions surrounding this issue. Let me know if you have any feedback.

Published Saturday, July 08, 2006 1:22 AM by chrisbal

Filed under: ,

Comments

# re: Merge Ahead @ Thursday, March 01, 2007 12:42 PM

If you need a title for your report -but that title causes the cursed merge cells problems - then you may try the following work around:

Create a bitmap image that contains the report title. Within BIDS choose the Report menu then Embedded Images. Add your bitmap to the list. Add a header to the report (from the Report menu again). Select the header and set the background image property to Source=Embedded, Value=The name of you embedded image.

The image will display when the report is rendered in the browser but will not appear if you save the results to an Excel spreadsheet.

JamesAndrewPlant

# The 2-for-1 Special in Excel @ Friday, March 09, 2007 3:23 PM

It inevitably happens when building SQL Server Reporting Services reports that someone will have desire

Strate SQL

# re: Merge Ahead @ Monday, May 21, 2007 10:50 PM

    I also had similar issues related to merged cells.

   Merged cells were present mostly in the regions which is interfering with left and right edges of report items in report header.

    So i tried to keep the header into excel header. This can be done by including SimplePageHeaders=true in device info. Another tips is to remove the blank columns by adding RemoveSpace item in device info.

A sample of reconfiguring device info thro Reportserver.config is pasted below.

<Extension Name="EXCEL" Type="Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer,Microsoft.ReportingServices.ExcelRendering">

<Configuration>

<DeviceInfo>

<SimplePageHeaders>true</SimplePageHeaders>

<RemoveSpace>0.012in</RemoveSpace>

</DeviceInfo>

</Configuration>

</Extension>

ajkarthik

# Reporting Frameworks Part 3 ??? using SQL Server 2005 Reporting Services &laquo; conservative geek @ Tuesday, October 16, 2007 11:34 PM

PingBack from http://conservativgeek.wordpress.com/2007/08/30/reporting-frameworks-part-3-%e2%80%93-using-sql-server-2005-reporting-services/

Reporting Frameworks Part 3 ??? using SQL Server 2005 Reporting Services « conservative geek

Anonymous comments are disabled
Page view tracker