apurbakarfa007 Posted August 4, 2018 Share Posted August 4, 2018 I am using two java swing Jtable, which hold some data and i want to print them, but i did not understand how to print two table one by one.Pleae help me... //This is my Codeprivate void print() { try { List numdata = new ArrayList();//jtdName First Java Swing Jtable. for (int count = 0; count < jtdName.getRowCount(); count++) { for (int cl = 0; cl < jtdName.getColumnCount(); cl++) { numdata.add(jtdName.getValueAt(count, cl).toString()); } }//jtbClass Second Java Swing Jtable. List classdata = new ArrayList(); for (int count = 0; count < jtbClass.getRowCount(); count++) { for (int cl = 0; cl < jtbClass.getColumnCount(); cl++) { classdata.add(jtbClass.getValueAt(count, cl).toString()); } } ArrayList<Object> datalist = new ArrayList(); datalist.add(numdata); datalist.add(classdata); String reportSource = "\TablePrint\src\print\PrintView.jrxml"; String reportDest = "\TablePrint\src\print\PrintView.jasper"; JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(datalist); JasperPrint jasperPrint; jasperPrint = JasperFillManager.fillReport(jasperReport, null, beanColDataSource); JasperExportManager.exportReportToHtmlFile( jasperPrint, reportDest); JasperViewer.viewReport(jasperPrint, false); } catch (JRException e) { } } 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