首页 文章

水晶报告打印和导出不起作用

提问于
浏览
0

我是.net开发者 . 现在我正在使用水晶报告 . 当我打印或导出水晶报告时,按下打印时打开对话框打开,则不会进行打印操作 . 此打印和导出不适用于火狐 . 只有chrome支持此功能 . 是否需要额外的代码来完成这项工作 .

---------------------------updated-----------------------------------------

在课堂申报:

public partial class EndUser_FS_File_History : System.Web.UI.Page
    {
        ReportDocument reportdocument = null;
        ..........

在负载水晶报告:

reportdocument = new ReportDocument();
                    string connectionString = ConfigurationManager.ConnectionStrings["FileSystemConnectionString"].ConnectionString;
                    SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);
                    reportdocument.Load(Server.MapPath(@"~/Admin/UserReport.rpt"));
                    reportdocument.SetDataSource(myDataSet);
                    reportdocument.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
                    CrystalReportViewer1.ReportSource = reportdocument;

并在Page_Unload事件:

protected void Page_Unload(object sender, EventArgs e)
    {
        if (reportdocument != null)
        {
            reportdocument.Close();
            reportdocument.Dispose();
        }
        GC.Collect();
    }

大量没有记录时仍会出现问题:

The maximum report processing jobs limit configured by your system administrator has been reached.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The maximum report processing jobs limit configured by your system administrator has been reached.

Source Error:


Line 782:                    string connectionString = ConfigurationManager.ConnectionStrings["FileSystemConnectionString"].ConnectionString;
Line 783:                    SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);
Line 784:                    reportdocument.Load(Server.MapPath(@"~/Admin/UserReport.rpt"));
Line 785:                    reportdocument.SetDataSource(myDataSet);
Line 786:                    reportdocument.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);


Source File: f:\EasyWeb\Admin\User_Management.aspx.cs    Line: 784

Stack Trace:


[COMException (0x80041016): The maximum report processing jobs limit configured by your system administrator has been reached.]
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +144
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +526

[CrystalReportsException: Load report failed.]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +621
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +1969
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +186
   Admin_User_Management.lbut_print_Click(Object sender, EventArgs e) in f:\EasyWeb\Admin\User_Management.aspx.cs:784
   System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

1 回答

  • 1

    步骤很少:

    在Pageload之前,将报告声明为

    ReportDocument rpt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
      try
         {
         rpt= new ReportName; //this is the name of your report
         // do all the logic here
         }
      catch()
         {
         }
    }
    
    protected void Page_Unload(object sender, EventArgs e)
    {
      if(rpt!=null)
       {
        rpt.Close();
        rpt.Dispose();
       }
      GC.Collect();
    }
    

相关问题