how to print multiple java swing table data ?

0

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 Code

private 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) {
        }
    }

 

apurbakarfa007's picture
Joined: Aug 3 2018 - 12:32pm
Last seen: 1 year 2 weeks ago

0 Answers:

No answers yet
Feedback