Jump to content
Changes to the Jaspersoft community edition download ×

how to print multiple java swing table data ?


Recommended Posts

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();

            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);

                    jasperPrint, reportDest);

            JasperViewer.viewReport(jasperPrint, false);
        } catch (JRException e) {


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...