代码之家  ›  专栏  ›  技术社区  ›  GordyII

向Microsoft Reporting Services中的Excel报表添加选项卡和命名选项卡

  •  2
  • GordyII  · 技术社区  · 17 年前

    在Microsoft Reporting Services中,我希望能够在生成Excel报表时为生成的文档命名选项卡。

    有人知道我怎么做吗?

    2 回复  |  直到 16 年前
        1
  •  2
  •   Colin Asquith    16 年前

    为了从Web前端解决这个问题(使用ReportViewer Web控件让我疯狂),我意识到SSR将数据作为一个字节数组返回,然后您可以对其进行处理。因此,在.NET中捕获流,您可以编写一个方法,其功能如下:

    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;
    }
    

    然后使用类似于 http://npoi.codeplex.com/ 或者作为字节或者创建某种类型的内存流,然后您可以让它做您想要做的任何事情。

    另外-请注意,SSRS(SQL Server Reporting Services)R2将具有此功能,但它将在2010年5月推出。 http://www.bidn.com/blogs/bretupdegraff/bidn-blog/234/new-features-of-ssrs-2008-r2-part-1-naming-excel-sheets-when-exporting-reports

        2
  •  1
  •   Miyagi Coder    17 年前

    如果要在导出时在选项卡中拆分报表,请使用带分页符的多个表。

    不能从SSR重命名选项卡。如果要重命名选项卡,则需要编写自定义代码。

    推荐文章