XDocReport:XDocConverterException:找不到来自=DOCX 的转换器
XDocReport : XDocConverterException: Cannot find converters from=DOCX
我正在测试 XDocReport 中的示例代码。我结合了,基于 docx 模板创建了 docx 和 pdf 报告。但是我不断收到此消息
Apr 21, 2016 5:39:10 PM fr.opensagres.xdocreport.converter.ConverterRegistry internalFindConverter
SEVERE: Cannot find converters from=DOCX
fr.opensagres.xdocreport.converter.XDocConverterException: Cannot find converters from=DOCX
at fr.opensagres.xdocreport.converter.ConverterRegistry.internalFindConverter(ConverterRegistry.java:121)
at fr.opensagres.xdocreport.converter.ConverterRegistry.findConverter(ConverterRegistry.java:74)
at fr.opensagres.xdocreport.document.AbstractXDocReport.getConverter(AbstractXDocReport.java:667)
at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:690)
at fr.opensagres.xdocreport.samples.docxandfreemarker.DocxProjectWithFreemarkerList.main(DocxProjectWithFreemarkerList.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
代码如下:
try
{
InputStream in = DocxProjectWithFreemarker.class.getResourceAsStream( "DocxProjectWithFreemarkerList.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Freemarker );
FieldsMetadata metadata = report.createFieldsMetadata();
metadata.load( "developers", Developer.class, true );
IContext context = report.createContext();
Project project = new Project( "XDocReport" );
context.put( "project", project );
List<Developer> developers = new ArrayList<Developer>();
developers.add( new Developer( "ZERR", "Angelo", "angelo.zerr@gmail.com" ) );
developers.add( new Developer( "Leclercq", "Pascal", "pascal.leclercq@gmail.com" ) );
context.put( "developers", developers );
OutputStream out = new FileOutputStream( new File( "DocxProjectWithFreemarkerList_Out.docx" ) );
report.process( context, out );
// ===========================================================================================
Options options = Options.getTo(ConverterTypeTo.PDF);
OutputStream outt = new FileOutputStream(new File("DocxProjectWithFreemarkerList_Out.pdf"));
report.convert(context, options, outt);
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
代码有问题吗?我该如何修复该错误?
您的问题与this issue相同。
您的类路径中需要 fr.opensagres.xdocreport.converter.docx.xwpf JAR 及其依赖项 JAR(iText 等)。
我正在测试 XDocReport 中的示例代码。我结合了,基于 docx 模板创建了 docx 和 pdf 报告。但是我不断收到此消息
Apr 21, 2016 5:39:10 PM fr.opensagres.xdocreport.converter.ConverterRegistry internalFindConverter
SEVERE: Cannot find converters from=DOCX
fr.opensagres.xdocreport.converter.XDocConverterException: Cannot find converters from=DOCX
at fr.opensagres.xdocreport.converter.ConverterRegistry.internalFindConverter(ConverterRegistry.java:121)
at fr.opensagres.xdocreport.converter.ConverterRegistry.findConverter(ConverterRegistry.java:74)
at fr.opensagres.xdocreport.document.AbstractXDocReport.getConverter(AbstractXDocReport.java:667)
at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:690)
at fr.opensagres.xdocreport.samples.docxandfreemarker.DocxProjectWithFreemarkerList.main(DocxProjectWithFreemarkerList.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
代码如下:
try
{
InputStream in = DocxProjectWithFreemarker.class.getResourceAsStream( "DocxProjectWithFreemarkerList.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Freemarker );
FieldsMetadata metadata = report.createFieldsMetadata();
metadata.load( "developers", Developer.class, true );
IContext context = report.createContext();
Project project = new Project( "XDocReport" );
context.put( "project", project );
List<Developer> developers = new ArrayList<Developer>();
developers.add( new Developer( "ZERR", "Angelo", "angelo.zerr@gmail.com" ) );
developers.add( new Developer( "Leclercq", "Pascal", "pascal.leclercq@gmail.com" ) );
context.put( "developers", developers );
OutputStream out = new FileOutputStream( new File( "DocxProjectWithFreemarkerList_Out.docx" ) );
report.process( context, out );
// ===========================================================================================
Options options = Options.getTo(ConverterTypeTo.PDF);
OutputStream outt = new FileOutputStream(new File("DocxProjectWithFreemarkerList_Out.pdf"));
report.convert(context, options, outt);
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
代码有问题吗?我该如何修复该错误?
您的问题与this issue相同。
您的类路径中需要 fr.opensagres.xdocreport.converter.docx.xwpf JAR 及其依赖项 JAR(iText 等)。