views:

674

answers:

2

In Microsoft Reporting Services, I want to be able to name the tabs for the resulting document when a excel report is generated.

Does anyone know how I can do this?

+1  A: 

If you want to break up a report in tabs when exporting, use mutiple tables with page breaks.

You can not rename tabs from SSRS. If you want to rename the tabs you will need to write custom code.

Miyagi Coder
Is there any source code around for this?
GordyII
You want sample code for renaming the tabs?
Miyagi Coder
Source code for the renaming would be good. Making the tabs seems simple enough.
GordyII
+2  A: 

To get around this issue from the web front end (which drove me crazy using the ReportViewer web control), I realised that SSRS returns the data as a byte array that you can then process. So capturing the stream in .NET you can write a method that does something like:

private byte[] ExportStream(string streamType, out string mimeType, out string extension)
{
    Microsoft.Reporting.WebForms.Warning[] warnings;
    string[] streamids;
    string encoding;
    string deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"

    byte[] bytes = ReportViewerClientReport.ServerReport.Render(streamType,
                          deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

    return bytes;
}

Then post-process the output from this method with something like the fantastic NPOI library from http://npoi.codeplex.com/ either as bytes or create some kind of memory stream, then you can make it do whatever you want.

Also- note that SSRS (Sql Server Reporting Services) R2 will have this feature, but it comes out in about May 2010. http://www.bidn.com/blogs/bretupdegraff/bidn-blog/234/new-features-of-ssrs-2008-r2-part-1-naming-excel-sheets-when-exporting-reports

Colin Asquith