[jasperreports-questions] simple jasper report in java without a database.

2010-04-05 Thread Abhijit Kamatkar
Dear all,



I hope you are doing good. I would like to know whether we can generate a
jasper report in java http://www.javaranch.com/ without using any database
connection. I know we can generate jasper report in java with database
connection. I have generated few reprts in .pdf and .xls format. Now I want
to display some text on the the jasper report in java without database, say
hello jasper. I am using ireport. I have creaated a file and in that file,
I have added a title in the title section $P{Report_title} . Now in the
program, i am declaring a hashmap and trying put value in the hasmap like,
hm.put(Report_title,Hello Report);

Later I am declaring JasperPrint like as follows.

JasperPrint print=JasperFillManager.fillReportToFile(fileName,
outFileNamePDF, hm);

Here I am having problem about type mismatch:cannot convert from void to
JasperPrint. I am not fully familiar with JasperReport API. I am trying to
learn it with some simple examples first.In order to get the data on the
report what I am supposed to do? Passing value from hashmap? Or shall use
any collections? I would appreciate your suggestions. Thanks in advance.
Please find the code. It's vary simple at the moment.


import java.util.HashMap;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
@SuppressWarnings(unchecked)
public class JasperSimple {
String fileName = C:\\Documents and
Settings\\abhijit\\JasperSimpleReport.jasper;
String outFileNamePDF = c:\\JasperSimpleReport.pdf;
HashMap hm = new HashMap();

public JasperSimple() {
super();
}
@SuppressWarnings(deprecation)

public void generateReport() throws ClassNotFoundException,
InstantiationException, IllegalAccessException {
try {
System.out.println(Filling report...);
hm.put($P{Report_title},Hello Report);
//JasperReport manager=JasperManager.compileReport(fileName);
JasperPrint print=JasperFillManager.fillReport(fileName, hm);
//byte[] bytes = JasperExportManager.exportReportToPdf(print);
//define and initialize jasperreport engine's exporter for .pdf
JRExporter exporter = new
net.sf.jasperreports.engine.export.JRPdfExporter();
//parameter used for the destined file.
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
outFileNamePDF);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
//export to .pdf
exporter.exportReport();
System.out.println(Created file:  + outFileNamePDF);
System.out.println(Done!);
} catch (JRException e) {
e.printStackTrace();
}
catch(Exception e1){
 e1.printStackTrace();
}
}
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException {
new JasperSimple().generateReport();
System.out.println(No. of argumetns are:  + args.length);
   for(int i= 0;i  args.length;i++)
  System.out.println(Argument  + i +  is :  + args[i]);
}
}
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions


[jasperreports-questions] Jasper report execution in java with parametrized query at run time

2010-03-25 Thread Abhijit Kamatkar
Hello,

I have been working on Jasper Reports. I have created few reports using
ireport and I was able to export these reports within java. Of course these
reports were simple. Now I want to get deeper in Jasper reports. I want to
know how one can execute jasper report in java with parametrized query at
run time. Has anyone worked on similar module? Do we need to create any .xml
at runtime for this? Right now the Jrxml file contains the query which was
written in the context while designing the report. Now, I want to run the
query dynamically. I am looking forward for your suggestions and advices.
Thank you in advance.

Best regards.
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions