Sql – Adding and Naming TABS to excel reports in Microsoft Reporting Services

reporting-servicessql server

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?

Best Answer

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