Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PDF格式的C#报告-生成1和#xBA的缓慢程度;报告_C#_Asp.net_Pdf Generation - Fatal编程技术网

PDF格式的C#报告-生成1和#xBA的缓慢程度;报告

PDF格式的C#报告-生成1和#xBA的缓慢程度;报告,c#,asp.net,pdf-generation,C#,Asp.net,Pdf Generation,我用C#编写了一段代码,用Crystal reports生成报告,并在浏览器上以PDF格式打开 当用户第一次登录系统并去生成其中一个报告时,需要很长时间来处理…但是,在生成第一个报告后,其他报告将自动生成 有人知道我做什么吗? 我的代码是: 单击按钮生成PDF时: ReportDocument Rel = new ReportDocument(); Rel.Load(Server.MapPath("../Reports/Report1.rpt")); Rel.SetParameterValue(

我用C#编写了一段代码,用Crystal reports生成报告,并在浏览器上以PDF格式打开

当用户第一次登录系统并去生成其中一个报告时,需要很长时间来处理…但是,在生成第一个报告后,其他报告将自动生成

有人知道我做什么吗? 我的代码是:

单击按钮生成PDF时:

ReportDocument Rel = new ReportDocument();
Rel.Load(Server.MapPath("../Reports/Report1.rpt"));
Rel.SetParameterValue("@Id", Id);

Session.Add("Report", Rel);
string _open = "window.open('Report.aspx');";
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), _open, true);
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Report"] != null)
                OpenPDF((ReportDocument)Session["Report"]);
        }
    }

private void OpenPDF(ReportDocument Rel)
{
    MemoryStream stream = (MemoryStream)Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "application/pdf";
    Response.BinaryWrite(stream.ToArray());
    Response.End();
}
在“Report.aspx”页面中:

ReportDocument Rel = new ReportDocument();
Rel.Load(Server.MapPath("../Reports/Report1.rpt"));
Rel.SetParameterValue("@Id", Id);

Session.Add("Report", Rel);
string _open = "window.open('Report.aspx');";
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), _open, true);
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Report"] != null)
                OpenPDF((ReportDocument)Session["Report"]);
        }
    }

private void OpenPDF(ReportDocument Rel)
{
    MemoryStream stream = (MemoryStream)Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "application/pdf";
    Response.BinaryWrite(stream.ToArray());
    Response.End();
}

谢谢

不确定报表文件包含的内容,以及它处理的页面是否比导出的页面多,但您可以为用户预加载运行时,以便后续报表呈现在执行时不会太明显

编辑:


创建一个空白报告并将其加载到某个位置,例如,在生成报告之前,加载上一页的页面;主页或小节。然后关闭并处理报告。此外,请从项目引用中删除您未使用的任何Crystal Reports程序集。

Hum…即使只有一页和几个项目的报告,在登录后的第一时间处理也会花费很多时间…我如何为用户预加载运行时?