2012-09-10 12 views
3

使用iReport,我生成報告以多種格式查看。對於我而言,是否可以忽略分頁僅適用於HTML等特定格式,其餘部分爲true不同格式的報告中的分頁

With isIgnorePagination="false" HTML預覽出現在區塊中。但是,將其設置爲true會使PDF輸出爲單頁。

有什麼建議嗎?

回答

3

爲什麼你可以。在導出報告之前,使用適當的值添加IS_IGNORE_PAGINATION。您可以在運行時根據導出格式設置值。

params.put("IS_IGNORE_PAGINATION", true); 
+0

感謝您的答覆。很明顯,僅靠iReport是不可能的。 –

+0

我發現這些鏈接[link1](http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/sample.reference/nopagebreak/index.html)&[link2](http://jasperforge.org/plugins/ espforum/view.php?group_id = 102&forumid = 103&topicid = 30269)非常有幫助。 –

+0

好吧,它必須在運行時發生。您可以在設計時通過iReport以某種方式進行設置,但這並不能達到您想要的效果。在實際導出之前,您必須將其添加到傳遞到報告中的參數圖中。 –

0

我發現這個問題的一個解決方案:

 paramaters.put("fromDate", fromDate); 
     paramaters.put("toDate", toDate); 
     if (!output.equals("pdf")) 
     { 
     paramaters.put("IS_IGNORE_PAGINATION", true); 
     } 
     else 
      paramaters.put("IS_IGNORE_PAGINATION", false); 


     JasperPrint jasperPrint = null; 
     jasperPrint = JasperFillManager.fillReport(CompiledReport, paramaters, connection); 


     if (output.equals("html")) { 
      generateHtmlResponse(response, jasperPrint); 
     } else if (output.equals("pdf")) { 
      generatePdfResponse(response, jasperPrint); 
     } else if(output.equals("excel")) { 
      generateXLResponse(response, jasperPrint); 
     }