imanol00 Posted May 23, 2007 Share Posted May 23, 2007 Hi jasper friends !! I have a problem creating a custom datasource because I want to use a tableModel as datasource in iReport. I don't need a SQL query because I have a tableModel with all the data. The source code in my class "CreateReport" is : try { //Ruta de Archivo Jasper String fileName = "C:Archivos de programaMiDirArchivo.jasper"; //Pasamos parametros al reporte Jasper. Map parameters = new HashMap(); parameters.put("titulo","Prueba"); parameters.put("colNombreEmpInf",tableModelEmp.getValueAt(0, 0)); parameters.put("colPassEmpInf",tableModelEmp.getValueAt(0, 1)); //Se establece la fuente de datos, que será una Tabla JRTableModelDataSource Tabledata = new JRTableModelDataSource(tableModelEmp); //Preparacion del reporte (en esta etapa llena el diseño de reporte) //Reporte diseñado y compilado con iReport //Se envia Modelo de tabla con datos en lugar de una conexion JasperPrint jasperPrint = JasperFillManager.fillReport(fileName,parameters,Tabledata); //Se lanza el Viewer de Jasper JasperViewer jviewer = new JasperViewer(jasperPrint,false); jviewer.show(); } catch (Exception j) { JOptionPane.showMessageDialog(null,"Mensaje de Error:"+j.getMessage(), "Excepción",JOptionPane.ERROR_MESSAGE); } I think that this code is OK. If not, please give me an answer. If someone know how to use iReport 1.3.3 or another version PLEASE answer me. I'm driving crazy with this problem. Thanks a lot for reading! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now