2014-09-10 67 views
0

因此,我正在對此進行一些研究,並且從我可以收集的信息來看,用於實現此目的的技術已被逐步淘汰。從控制器發送渲染報告到一個視圖

我有一個RDLC文件。我試圖使用LocalReport類,但它似乎嚴重不喜歡接收呈現的報告。我正在使用MVC5。

任何人都可以推薦一些我可以看作是替代使用LocalReport類或RDLC文件的東西。或者任何人都能夠提供一些關於如何正確執行此操作的見解。

請讓我知道你是否想看看我使用的一些代碼。

謝謝:)

回答

0

好吧好吧,我設法避開我的問題是這樣的:

我創建報告,並將其保存到被每天刪除的臨時文件夾。

System.IO.File.WriteAllBytes(Server.MapPath("/TempReports/report.pdf"), renderedBytes); 

我的控制器操作只是返回了一個鏈接到呈現的報告。

JavaScript的:

function GenerateReport() { 
     $.ajax({ 
      type: "POST", 
      url: "/Reporting/ReportAction", 
      data: { param1: "", param2: "" }, 
      success: function (data) { 
       var ua = window.navigator.userAgent; 
       var msie = ua.indexOf("MSIE "); 
       if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { 
        //set of functions specific to IE 
        var success = new PDFObject({ url: data }).embed("reportGenIe"); 
        $("#reportGenIe").attr('hidden', false); 
       } 
       else { 
        //Normal browsers 
        var success = new PDFObject({ url: data }).embed("reportGen"); 
       } 
      }, 
      error: function() { 
       alert("Unable to generate the report."); 
      } 
     }); 

對於IE我使用的iFrame和其他瀏覽器我使用的物體

<div role="content" style="padding-bottom:20px; height:650px !important"> 
    <iframe id="reportGenIe" hidden="hidden"></iframe> 
    <object id="reportGen"></object> 
</div> 

這包括圍繞IE得到拒絕動態地顯示一個pdf我。

我使用了PDFObject js庫,它似乎已經完成了這個技巧。 http://pdfobject.com/

相關問題