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

JasperReport Tool


2004 IR Help

Recommended Posts

By: Chetan - someone_genius

JasperReport Tool

2005-06-14 00:09

Hello!

 

I have developed a wrapper class around the various functionalities of JasperReport.

 

Kindly give me a feedback / suggestion so that I can make is more perfact.

 

Reg,

Chetan

 

Code:
 
import java.sql.Connection;
import java.util.HashMap;
import java.io.File;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.view.save.JRCsvSaveContributor;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.view.save.JRMultipleSheetsXlsSaveContributor;
import net.sf.jasperreports.view.save.JRSingleSheetXlsSaveContributor;

public class ReportManager {

private String jasperFile;
private String outputFile;
private Connection con;
private HashMap parameters;

public ReportManager() {
}

public void setConnection(Connection con) {
this.con = con;
}

public void setParameter(HashMap parameters) {
this.parameters = parameters;
}

public void setJasperFile(String jasperFile) {
this.jasperFile = jasperFile;
}

public void setOutputFile(String outputFile) {
this.outputFile = outputFile;
}

public void saveAsHTML()
throws JRException {
JasperExportManager.exportReportToHtmlFile(jasperFile, outputFile);
}

public void saveAsPDF()
throws JRException {
JasperExportManager.exportReportToPdfFile(jasperFile, outputFile);
}

public void saveAsXML(boolean withImage)
throws JRException {
JasperExportManager.exportReportToXmlFile(jasperFile, outputFile, withImage);
}

public void saveAsXLS(boolean isMultipleSheet)
throws JRException {

if(isMultipleSheet) {
new JRMultipleSheetsXlsSaveContributor().save(
JasperFillManager.fillReport(jasperFile, parameters, con),
new File(outputFile));
} else {
new JRSingleSheetXlsSaveContributor().save(
JasperFillManager.fillReport(jasperFile, parameters, con),
new File(outputFile));
}
}

public void saveAsCsv()
throws JRException {
new JRCsvSaveContributor().save(JasperFillManager.fillReport(jasperFile, parameters, con),
new File(outputFile));
}

public byte[] getPDF()
throws JRException{
return JasperExportManager.exportReportToPdf(
JasperFillManager.fillReport(jasperFile, parameters, con));
}
}

 

 

 

 

By: C-Box - c-box

RE: JasperReport Tool

2005-06-14 00:52

Hmmm ... what for should it be??? As this isn't within the JasperSource I wouldn't use such a "additional" wrapper class just to have the "common/most used" functions in one class.... when Teodor changes something the wrapper class also must be changed... so I'd prefer using the provided Jasper classes instead. I guess Teodor has built the Jasper[function]Manager classes for easy method access, or Is it to complex for you, to use these given methods?

 

just my two cent

C-Box

 

 

 

 

By: Chetan - someone_genius

RE: JasperReport Tool

2005-06-16 00:56

I have shared the same concerns as you in the beginning.

 

But we are going to use it in an application that will have average 30 concurrent uses. Hence we need to do pooling with the Reporting Tool, hence I developed a common class that we can pool.

Link to comment
Share on other sites

  • Replies 0
  • 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...