Io ho fatto così in una mia applicazione
Nella grafica stampa è un bottone
Ecco la classe reportCodice PHP:
stampa.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
new Reporter(conn).start();
}
});
E il gioco è fatto.Codice PHP:public class Reporter extends Thread {
private JasperPrint jp;
private String REPORTS_FOLDER = "C:\\";//File .jrxml
private Connection conn;
public Reporter(Connection conn){
this.conn=conn;
}
public void run() {
String reportName="Prova";
String reportPath = REPORTS_FOLDER + reportName;
JasperReport jr = null;
try {
jr=ReportLoader.loadReport(reportPath);
jp = ReportFiller.fillReport(conn, null, jr);
new JasperViewer(jp,false).setVisible(true);
} catch (JRException jre) {
JOptionPane.showMessageDialog(null,"Errore nella creazione del report");
}
}
}
Fammi Sapere

Rispondi quotando