0

i have developed application in JSF 1.2, RichFaces and running on Apache Tomcat. Have used JasperReports (with iReport 4) to generate pdf file from application and its perfectly ok. Now i want to export same files to excel instead of pdf. I used following code snippet but get error

net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: \reports\studentReports\testExcel.jrprint

The Code snippiet for generating to excel is as follows:-

File file = new File("/reports/studentReports/testExcel.jrprint");
JasperPrint jasperPrint = (JasperPrint)
JRLoader.loadObject(file);
JExcelApiExporter xlsExporter = new JExcelApiExporter();
xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
xlsExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"/reports/studentReports" + "/" + "testExcel1" + ".xls");
System.out.println("Exporting report...");
xlsExporter.exportReport();

I have checked, the path to report is correct. Where am i doing wrong. Thanks in advance.

learner
  • 757
  • 2
  • 14
  • 35
  • DId you try using the full path? – Fabiotocchi Apr 12 '13 at 09:57
  • can u tell me how to do that in jsf code? – learner Apr 12 '13 at 10:00
  • I mean, when you search for the path in `File file = new File("/reports/studentReports/testExcel.jrprint");´ did you try searching for the full path like "C:/Documents and settings/user/documents/eworkspace/...." – Fabiotocchi Apr 12 '13 at 10:06
  • Assuming a Windows environment with the server installed on `C:/` disk, the code as you have expects the file to be in `C:/reports/studentReports/testExcel.jrprint`. Is this true? If not (the exception confirms this, by the way), where exactly is that file located then? You should specify exactly that location in `new File()`. – BalusC Apr 12 '13 at 12:25

0 Answers0