Created
June 27, 2017 15:47
-
-
Save edilsoncichon/9147b75df8e1a3992983b91788f14e03 to your computer and use it in GitHub Desktop.
Solution for working with modal window and JasperReport / iReport. / Solução para se trabalhar com janela modal e JasperReport/iReport.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void gerarReport(String filePath, List list) throws Exception { | |
JDialog dialogReport = new JDialog(new javax.swing.JFrame(), "TITLE REPORT", true); | |
dialogReport.setSize(1000, 700); | |
dialogReport.setLocationRelativeTo(null); | |
InputStream fileReport = getClass().getResourceAsStream(filePath); | |
Map params = new HashMap(); | |
JRBeanCollectionDataSource dataList = new JRBeanCollectionDataSource(list); | |
JasperPrint print = JasperFillManager.fillReport(fileReport, params, dataList); | |
JasperViewer windowJasper = new JasperViewer(print, true); | |
dialogReport.getContentPane().add(windowJasper.getContentPane()); | |
if ( print.getPages().size() > 0 ) | |
dialogReport.setVisible(true); | |
else | |
throw new Exception("No Pages!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment