代码之家  ›  专栏  ›  技术社区  ›  S M Kamran

VS2008 CR报表查看器。打印并导出到PDF不起作用

  •  4
  • S M Kamran  · 技术社区  · 14 年前

    我在VS2008有一个网络项目。问题是从Web报表查看器;报表无法打印或导出为PDF格式。报表显示正常,但当按下打印按钮或导出按钮时,不会发生任何事情。没有错误或崩溃。只是什么都没发生。默认打印机设置正确,我可以从那台机器上打印。我是不是错过了什么????

    早些时候,当我将应用程序安装到一个新的虚拟目录中时,报告没有显示,然后我将aspnet_client文件夹复制到我新创建的web应用程序根目录中,然后使报告可见。但是打印和导出功能不起作用。

    2 回复  |  直到 14 年前
        1
  •  1
  •   bulltorious    14 年前

    您是否正在维护报表文档本身的状态?我必须将报告添加到会话中,并在页面加载时重置报告源。

        ReportDocument report = new ReportDocument();
            report.Load(Server.MapPath("blargh.rpt"));
            //...
            rptViewer.ReportSource = report;
    

    session[constants.session.report]=报告;

    protected void Page_Load(object sender, EventArgs e)
        {//detects wether or not the RepoerViewer should be displayed again, to avoid it displaying an empty modal box.
            if (hdfDisplayCrystalReport.Value == "Yes")
            {
    
                rptViewer.ReportSource = (ReportDocument)Session[Constants.Session.Report];
    
            }
    
    
            if (rptViewer.ReportSource == null)
            {
                hdfDisplayCrystalReport.Value = string.Empty;
    
            }
    

    }

        2
  •  0
  •   Eduardo Molteni    14 年前

    您是在UpdatePanel中使用报告吗?如果是,请检查是否已将触发器置于面板内:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
          <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
              DisplayGroupTree="False" oninit="CrystalReportViewer1_Init" />
       </ContentTemplate>
       <Triggers> 
          <asp:PostBackTrigger ControlID="CrystalReportViewer1"/>
       </Triggers>
    </asp:UpdatePanel>
    

    同时检查你是否有 ViewState 为页面启用