簡體   English   中英

Crystal Reports-在MVC中導出為pdf

[英]Crystal Reports - export to pdf in MVC

我在我的應用程序中集成了以下代碼,以使用MVC項目中的Crystal報表生成“ pdf”文件。 但是,在處理了請求之后,我只能在pdf文件中看到2頁,而我的“數據”返回的記錄超過2條。 另外,頁面處理后不會立即呈現pdf,但是我必須至少刷新一次,然后才能在瀏覽器中呈現pdf。

using CrystalDecisions.CrystalReports.Engine;

public FileStreamResult Report()
{
    ReportClass rptH = new ReportClass();
    List<sampledataset> data = objdb.getdataset();
    rptH.FileName = Server.MapPath("[reportName].rpt");
    rptH.Load();
    rptH.SetDatabaseLogon("un", "pwd", "server", "db");
    rptH.SetDataSource(data);
    Stream stream = rptH.ExportToStream
       (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
    stream.Seek(0, System.IO.SeekOrigin.Begin);
    return new FileStreamResult(stream, "application/pdf");   
}

我把代碼從這里的SO,但修改了它喜歡的上方。

TIA。

編輯 :這適用於Firefox,而不是IE7。

我終於在這里找到了解決方案。 它與MVC無關,而是IE處理彈出窗口的方式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM