2014-01-27 87 views
0

我的報告包含超過1200多頁,我想將其導出爲PDF。我正在使用ASP.NET。將超過1200頁的報告導出爲PDF

目前,出口需要2個多小時。我正在使用Pull方法。我怎樣才能優化這個過程?

ReportDocument rpt = new ReportDocument(); 
protected void Page_Load(object sender, EventArgs e) 
{ 
    ReportsTest dsFams = new ReportsTest(); 
    string condition = Session["cond"].ToString(); 
    if (!IsPostBack) 
    { 
     DataSet ds = new DataSet(); 
     tblFA_ItemSetupTableAdapter tblItemSetup = new tblFA_ItemSetupTableAdapter(); 

     if (condition.Contains("{tblFA_ItemSetup.ParentCatID}")) 
     { 
      tblItemSetup.FillByParentCatID(dsFams.tblFA_ItemSetup, Session["holdbranch"].ToString(), Session["ParentCat"].ToString()); 
      ds.Tables.Add(tblItemSetup.GetDataByParentCatID(Session["holdbranch"].ToString(), Session["ParentCat"].ToString()).Copy()); 
     } 
     else 
     { 
      tblItemSetup.Fill(dsFams.tblFA_ItemSetup); 
      ds.Tables.Add(tblItemSetup.GetData()); 
     } 

     Cache["dtImages"] = ds; 
    } 
    rpt.Load(Server.MapPath("~/rptFA_ItemTag.rpt")); 

    rpt.SetDataSource((DataSet)Cache["dtImages"]); 
    CrystalReportViewer1.EnableDatabaseLogonPrompt = false; 
    CrystalReportViewer1.ReportSource = rpt; 
} 

這是按一下按鈕代碼:

rpt.Load(Server.MapPath("~/rptFA_ItemTag.rpt")); 
rpt.SetDataSource((DataSet)Cache["dtImages"]); 
System.IO.Stream oStream; 
byte[] byteArray = null; 
oStream = rpt.ExportToStream(ExportFormatType.PortableDocFormat); 
byteArray = new byte[oStream.Length]; 
oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); 
Response.ClearContent(); 
Response.ClearHeaders(); 
Response.ContentType = "application/pdf"; 
Response.BinaryWrite(byteArray); 
Response.Flush(); 
Response.Close(); 
+0

你能提供一些代碼嗎? – vikky

+0

我提供我的代碼 –

回答

0

如果你只想導出到你並不需要一個報表查看器的PDF文件。 您可以刪除這兩行並保存一些渲染: CrystalReportViewer1.EnableDatabaseLogonPrompt = false; CrystalReportViewer1.ReportSource = rpt;