Skip to content

Instantly share code, notes, and snippets.

@john-evangelist
Created July 17, 2014 07:24
Show Gist options
  • Save john-evangelist/5759eb4998296ce0674c to your computer and use it in GitHub Desktop.
Save john-evangelist/5759eb4998296ce0674c to your computer and use it in GitHub Desktop.
public void makeReport(){
try{
JasperReport jasperReport = JasperManager.compileReport("pathToJRXML");
Map params = new HashMap();
params.put("key",123);
/**constroi o report
*@param jasperReport o jrxml carregado
*@param params
*@dataSource conexação com o banco
**/
JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, params, dataSource);
//exporta o report para um arquivo pdf no disco
JasperManager.printReportToPdfFile(jasperPrint, "pathToExport");
//OU
//exibe a view do report
JasperView.viewReport(jasperPrint);
}catch(JRException e){
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment