Bonjour,
J'essaie de remplir les champs de mon .jasper avec ce petit programme java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| public class Export{
public static void main(String[] argv){
System.out.println("test sarah --- main");
Collection sarah = new ArrayList();
String libExperiences = new String("libExperiences");
String libFormations = new String("libFormations");
String dateDebut = new String("dateDebut");
String dateFin = new String("dateFin");
String isExperience = new String("isExperience");
String isFormation = new String("isFormation");
String nomEntreprise = new String("nomEntreprise");
String posteEntreprise = new String("posteEntreprise");
String formation = new String("formation");
sarah.add(libExperiences);
sarah.add(libFormations);
sarah.add(dateDebut);
sarah.add(dateFin);
sarah.add(isExperience);
sarah.add(isFormation);
sarah.add(nomEntreprise);
sarah.add(posteEntreprise);
sarah.add(formation);
try{
System.out.println("Avant la generation");
JasperReport jasperReport = (JasperReport)JRLoader.loadObject("D:/projects/anpe/workspace/test_sarah/jasper/CV_test.jasper");
System.out.println("Test 1");
Map parameters = new HashMap();
System.out.println("Test 2");
JRBeanCollectionDataSource source = new JRBeanCollectionDataSource(sarah);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, source);
System.out.println("Test 3");
JasperExportManager.exportReportToPdfFile(jasperPrint, "D:/classic.pdf");
System.out.println("Apres la generation");
}catch (JRException e) {
e.printStackTrace();
}
}
} |
J'ai bien défini tous les champs du .jasper, mais j'ai cette exception au moment de l'exécution :
net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : libExperiences
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:116)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:93)
at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:104)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:799)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:763)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1078)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:107)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:751)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:679)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at Export.main(Export.java:64)
Caused by: java.lang.NoSuchMethodException: Unknown property 'libExperiences'
at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:1175)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:772)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:104)
... 11 more
Merci de votre aide !
Partager