2013-02-04 33 views
0

我正在使用Java程序中使用iReport生成的* .jasper報表。我需要以編程方式更改報告方向。這是我的代碼:在Java中更改Jasper報表的頁面方向

final File template = new File("report.jasper"); 
final JasperReport jasperReport = (JasperReport) JRLoader.loadObject(template); 
//connection is defined previously 
final JasperPrint print = JasperFillManager.fillReport(jasperReport, metadata, connection); 
//reprot.jasper is defined with LANDSCAPE orientation 
print.setOrientation(OrientationEnum.PORTRAIT); 

最後一行對生成的pdf或屏幕組件都沒有影響。

任何想法?

回答

0

更改JasperPrint對象的方向不會改變生成的頁面的寬度或高度。 我認爲您需要在報告填寫前更改頁面方向。

更多details