3

I cannot manage with this problem. The source is:

        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();
      }

When I'm trying to proceed this code I've got error:

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)

And it points to the line:

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

What does it mean - The report loader supports only [] files type.? It there anything wrong with loading data from the InputStream? I've no idea how to solve this. Please help!

oers
  • 18,436
  • 13
  • 66
  • 75
robson
  • 1,623
  • 8
  • 28
  • 43
  • 1
    Ok, got it. There was library for required type missing: fr.opensagres.xdocreport.document.docx - so, there were no any types known :-) – robson Mar 30 '12 at 12:35

1 Answers1

6

Your error means that you have not XDocReport fr.opensagres.xdocreport.document.docx docx implementation JAR in your classpath. I suggest you to read the Docx Reporting which explains that and XDocReport download samples which contains the well JARs according that you wish to do (use Velocity/Freemarker, generatefrom ODT, Docx...)

David Nehme
  • 21,379
  • 8
  • 78
  • 117
Angelo
  • 2,027
  • 13
  • 17