我无法解决这个问题。来源是:
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 加载数据有什么问题吗?我不知道如何解决这个问题。请帮忙!