I have created, using a jasper designer (not iReport but a plugin for eclipse), a report that uses an excel file as datasource.
the report works fine, in the designer, and read the data from the file without problems but after compiling the file to file.jasper
and giving him the excel file's path nothing apears in the JasperViewer!
This is my code:
try{
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("DataFile", "jasper_export.xls");
JasperPrint jasperPrint = JasperFillManager.fillReport(new FileInputStream(new File("file.jasper")), parameters,conn);
JasperViewer jv = new JasperViewer(jasperPrint, false);
jv.setVisible(true);
} catch (Exception ex) {
ex.printStackTrace();
}
SOLUTION:
This code woks perfect: