2012-03-30 9 views
1

Ich kann mit diesem Problem nicht fertig werden. Die Quelle ist:xDocReport - Es ist unmöglich, einen Bericht für den Eingabestream zu erstellen

 try { 
     // 1) Load Docx file by filling Velocity template engine and cache it to the registry 
     InputStream in = new FileInputStream("/test.docx"); 
     IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in,TemplateEngineKind.Velocity); 

     // 2) Create context Java model 
     IContext context = report.createContext(); 
     context.put("user", variables.get("user")); 

     // 3) Generate report by merging Java model with the Docx 
     OutputStream out = new FileOutputStream(new File("/test_Out.docx")); 
     report.process(context, out); 

     } catch (IOException e) { 
     e.printStackTrace(); 
     } catch (XDocReportException e) { 
     e.printStackTrace(); 
     } 

Wenn ich versuche, diesen Code zu gehen ich Fehler habe:

09:03:15,608 ERROR [stderr] (http--127.0.0.1-8080-1) fr.opensagres.xdocreport.core.XDocReportException: Impossible to create report for the input stream. The report loader supports only [] files type. 

09:03:15,608 ERROR [stderr] (http--127.0.0.1-8080-1) at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.createReport(XDocReportRegistry.java:328) 

09:03:15,608 ERROR [stderr] (http--127.0.0.1-8080-1) at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.createReport(XDocReportRegistry.java:313) 

09:03:15,608 ERROR [stderr] (http--127.0.0.1-8080-1) at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:285) 

09:03:15,608 ERROR [stderr] (http--127.0.0.1-8080-1) at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:278) 

09:03:15,608 ERROR [stderr] (http--127.0.0.1-8080-1) at fr.opensagres.xdocreport.document.registry.XDocReportRegistry.loadReport(XDocReportRegistry.java:264) 

Und es zeigt auf die Zeile:

IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in,TemplateEngineKind.Velocity); 

Was sie tut, Mittelwert - Der Berichtslader unterstützt nur den Dateityp []. Gibt es etwas falsch beim Laden von Daten aus dem InputStream? Ich habe keine Ahnung, wie ich das lösen soll. Bitte helfen Sie!

+1

Ok, hab es. Es gab eine Bibliothek für den benötigten Typ fehlt: fr.opensagres.xdocreport.document.docx - also waren keine Typen bekannt :-) – robson

Antwort

3

Ihr Fehler bedeutet, dass Sie nicht XDocReport fr.opensagres.xdocreport.document.docx docx Implementierung JAR in Ihrem Klassenpfad haben. Ich empfehle Ihnen, die Docx Reporting zu lesen, die das erklärt, und XDocReport download samples, die die Brunnen JARs enthält, die Sie tun möchten (Velocity/Freemarker, Generatefrom ODT, Docx ...)