Jump to content
We've recently updated our Privacy Statement, available here ×

call jasper report in java


shanthusharma

Recommended Posts

I have a .jrxml file, its got data from .csv file. all are working properly. and also i saved the output into .pdf file. but now i got a problem. when i tried to call my pdf file into java swing using jeditorpane. setpage(). its wont display some times its display the no protocol error at run time.

My problem is

I want to display the pdf fill, when i click the button in java, it has to display.

Can any one guide the correct way

this is the coding

try{

        JRCsvDataSource jcvs;
        char fieldDelimiter = '~';
        String recordDelimiter = "n";
        String outFileName ="Drep.pdf";

         URL csvurl = getClass().getResource("drep.csv");
          String csvpath = csvurl.getPath().replaceAll("%20"," ");
          File csv = new File(csvpath);
          jcvs = new JRCsvDataSource(new File(csv.getAbsolutePath()));
          jcvs.setFieldDelimiter(fieldDelimiter);
          jcvs.setRecordDelimiter(recordDelimiter);
          jcvs.setUseFirstRowAsHeader(true);
          URL jasurl = getClass().getResource("DRep.jasper");
          String jaspath = jasurl.getPath().replaceAll("%20"," ");
          JasperPrint jasperPrint = JasperFillManager.fillReport(jaspath,null,jcvs);
          JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
          exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
          exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,outFileName);
          exporter.exportReport();
          URL rurl = getClass().getResource("Dpooja.pdf");
          jedPan.setPage(rurl);
}

Thanks i advance

 

 

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...