gpt4 book ai didi

X文档报告 : XDocConverterException: Cannot find converters from=DOCX

转载 作者:行者123 更新时间:2023-12-01 12:28:47 24 4
gpt4 key购买 nike

我正在测试 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 等)。

关于X文档报告 : XDocConverterException: Cannot find converters from=DOCX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36766046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com