我无法解决这个问题。来源是:
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();
}
当我试图继续执行此代码时,我遇到了错误:
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)
它指向了这一行:
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in,TemplateEngineKind.Velocity);
含义是什么 - 报表加载器仅支持[]文件类型。 从InputStream加载数据有什么问题吗? 我不知道如何解决这个问题。请帮忙!
答案 0 :(得分:4)
您的错误意味着您的类路径中没有XDocReport fr.opensagres.xdocreport.document.docx docx实现JAR。我建议你阅读Docx Reporting解释那个和XDocReport download samples,其中包含你希望做的井JAR(使用Velocity / Freemarker,从ODT生成,Docx ......)