【问题标题】:SQL Server Reporting Services: how to print reports automatically without preview from a web applicationSQL Server Reporting Services:如何在不从 Web 应用程序预览的情况下自动打印报告
【发布时间】:2010-11-04 03:50:14
【问题描述】:

我正在使用 SQL Server Reporting Services 并在 ASP.NET 的 Web 应用程序中查看报告。 为了显示报表,我使用了报表查看器 Web 控件,它带来了导出报表和/或打印报表的功能,但需要在打印之前显示报表的预览。

我需要打印报告而不在网页中进行预览? 似乎有一种方法可以在 WinForms 中做到这一点,但我没有找到在 WebForms 中做到这一点的方法。 有什么想法吗?

谢谢 大卫

【问题讨论】:

    标签: asp.net ssrs-2008


    【解决方案1】:

    我认为这是不可能的。 SSRS webforms reportviewer 非常严格。

    更糟糕的是:打印功能只存在于IE中,其他浏览器不存在。 Firefox、Safari、Chrome 和 Opera 用户必须以 PDF 或 Word 格式下载文件并从那里打印。

    【讨论】:

      【解决方案2】:

      我在不使用 ReportViewer 控件的情况下呈现 SSRS 报告,最近使用的是 LocalReports。您可以在代码中配置 ReportViewer,强制它生成 PDF,并获取 PDF 的字节流。我停在那里并将PDF呈现到我的一组要求的屏幕b / c上,但我确信找到一种打印PDF文件字节流的方法要容易得多,然后处理任何与报告查看器。

      以下是如何将 LocalReport 转换为 PDF 文件的字节数组:

      LocalReport lclRpt = new LocalReport();
      //Do Stuff like bind DataSources, ReportParameters, SubReportProcessing Delegates, etc.
      string strMIMEType = String.Empty;
      string strEncoding = String.Empty;
      string strFileNameExtension = string.Empty;
      string[] strarrStreams;
      Warning[] warnLocalReportWarnings;
      byte[] bytarrPDF = lclRpt.Render("PDF", "<DeviceInfo><StartPage>0</StartPage></DeviceInfo>", out strMIMEType, out strEncoding, out strFileNameExtension, out strarrStreams, out warnLocalReportWarnings);
      return bytarrPDF;
      

      我不是 100% 知道如何完成您的最后一步,可能需要一个 .pdf 实用程序,或者可能有一种方法可以直接从代码中完成。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-01-23
        • 2023-01-12
        • 1970-01-01
        • 2023-03-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多