2014-09-01 108 views
0

我想在asp.net mvc應用程序中以pdf格式創建報表,並且此時我將部分視圖顯示爲結果,即,我的主頁是Report並且正在調用如爲部分視圖列表創建RazorPDF

public ActionResult Report(int id) 
{ 
    ViewBag.Id =id; 
    return View(); 
} 

而且裏面Report.cshtml我打電話5的局部視圖渲染報告 的5個不同的部分是這樣

<div class="row"> 
@Html.Action("Report1", "Screening", new { Id = @ViewBag.Id }) 
</div> 
<div class="row"> 
@Html.Action("Report2", "Screening", new { Id = @ViewBag.Id }) 
</div> 
<div class="row"> 
@Html.Action("Report3", "Screening", new { Id = @ViewBag.Id }) 
</div> 
<div class="row"> 
@Html.Action("Report4", "Screening", new { Id = @ViewBag.Id }) 
</div> 

現在我想打報告爲PDF和任何方式調用部分直接從RazorPDF視圖查看?

回答

0

你試過嗎?

public ActionResult Report(int id) 
{ 
    ViewBag.Id =id; 
    var model=new YourViewModel() 
    return new RazorPDF.PdfResult(model, "Report"); 
} 
+0

否這是行不通的。第一個問題Viebag.Id在視圖級別爲null,但我設法使用id屬性的模型來幫助它,並使用id屬性傳遞值來查看。但是,當頁面加載時,我收到一條警告:「處理頁面時出現錯誤」,並且當我打開PDF時,它給出的消息是「處理頁面時發生錯誤,讀取此文檔時出現問題(109)」。任何幫助解決它 – 2014-09-01 12:41:37

+0

不知道什麼確切的錯誤是什麼? – 2014-09-01 12:45:54