【问题标题】:How to Insert Images In Birt At Runtime Language (Java)如何在运行时语言 (Java) 中插入图像
【发布时间】:2018-11-23 05:09:40
【问题描述】:

我能够在我的 Rcp 应用程序中创建一个 Birt 报告,但问题是我无法将图像添加到我的表格数据(单元格数据)中

图像的路径或位置在我的工作区中。我的问题是如何为将在报告表中显示的图像设置路径或位置。我们有图像处理程序的 SetURL 方法,但它给出了如下错误

TextItemHandle cellData = null;
CellHandle contenCell = null;
contentCell = (CellHandle) tabledetail.getCells().get(0);
cellData = designFactory.newTextItem(value);
cellData.setContent(value.replace(" ", ""));
cellData.setProperty("canShrink", "false");

cellData.getPropertyHandle(StyleHandle.FONT_SIZE_PROP).setIntValue(10);

image = designFactory.newImage("");
image.setURL("platform:/plugin/com.****.reportgeneration/images/Information-icon.gif");
contentCell.getContent().add(cellData);   
contentCell.getContent().add(image);

全栈异常

org.eclipse.birt.report.engine.api.EngineException:运行报告时发生错误。 在 org.eclipse.birt.report.engine.api.impl.EngineTask.handleFatalExceptions(EngineTask.java:2375) 在 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:191) 在 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77) 在 com.****.reportgeneration.popup.actions.ModuleReportGeneration.createReportFolder(ModuleReportGeneration.java:465) 在 com.****.reportgeneration.popup.actions.ModuleReportGeneration.access$0(ModuleReportGeneration.java:402) 在 com.****.reportgeneration.popup.actions.ModuleReportGeneration$1.run(ModuleReportGeneration.java:325) 在 org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119) 原因:org.mozilla.javascript.EvaluatorException:正则表达式后的标志无效(#1) 在 org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77) 在 org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64) 在 org.mozilla.javascript.Parser.addError(Parser.java:188) 在 org.mozilla.javascript.Parser.addError(Parser.java:166) 在 org.mozilla.javascript.Parser.reportError(Parser.java:223) 在 org.mozilla.javascript.Parser.reportError(Parser.java:210) 在 org.mozilla.javascript.Parser.reportError(Parser.java:203) 在 org.mozilla.javascript.TokenStream.readRegExp(TokenStream.java:921) 在 org.mozilla.javascript.Parser.primaryExpr(Parser.java:2798) 在 org.mozilla.javascript.Parser.memberExpr(Parser.java:2406) 在 org.mozilla.javascript.Parser.unaryExpr(Parser.java:2304) 在 org.mozilla.javascript.Parser.mulExpr(Parser.java:2229) 在 org.mozilla.javascript.Parser.addExpr(Parser.java:2213) 在 org.mozilla.javascript.Parser.shiftExpr(Parser.java:2194) 在 org.mozilla.javascript.Parser.relExpr(Parser.java:2169) 在 org.mozilla.javascript.Parser.eqExpr(Parser.java:2141) 在 org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2130) 在 org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2119) 在 org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2108) 在 org.mozilla.javascript.Parser.andExpr(Parser.java:2097) 在 org.mozilla.javascript.Parser.orExpr(Parser.java:2086) 在 org.mozilla.javascript.Parser.condExpr(Parser.java:2062) 在 org.mozilla.javascript.Parser.assignExpr(Parser.java:2033) 在 org.mozilla.javascript.Parser.expr(Parser.java:2012) 在 org.mozilla.javascript.Parser.statementHelper(Parser.java:1039) 在 org.mozilla.javascript.Parser.nameOrLabel(Parser.java:1793) 在 org.mozilla.javascript.Parser.statementHelper(Parser.java:1032) 在 org.mozilla.javascript.Parser.statement(Parser.java:901) 在 org.mozilla.javascript.Parser.parse(Parser.java:540) 在 org.mozilla.javascript.Parser.parse(Parser.java:478) 在 org.mozilla.javascript.Context.compileImpl(Context.java:2348) 在 org.mozilla.javascript.Context.compileString(Context.java:1335) 在 org.mozilla.javascript.Context.compileString(Context.java:1324) 在 org.eclipse.birt.report.engine.javascript.JavascriptEngine$3.run(JavascriptEngine.java:240) 在 org.eclipse.birt.report.engine.javascript.JavascriptEngine$3.run(JavascriptEngine.java:1) 在 java.security.AccessController.doPrivileged(本机方法) 在 org.eclipse.birt.report.engine.javascript.JavascriptEngine.compile(JavascriptEngine.java:236) 在 org.eclipse.birt.report.engine.javascript.JavascriptEngine.compile(JavascriptEngine.java:1) 在 org.eclipse.birt.core.script.ScriptContext.compile(ScriptContext.java:153) 在 org.eclipse.birt.report.engine.executor.ExecutionContext.compile(ExecutionContext.java:779) 在 org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:713) 在 org.eclipse.birt.report.engine.executor.ReportItemExecutor.evaluateString(ReportItemExecutor.java:297) 在 org.eclipse.birt.report.engine.executor.ImageItemExecutor.handleURIImage(ImageItemExecutor.java:261) 在 org.eclipse.birt.report.engine.executor.ImageItemExecutor.handleImage(ImageItemExecutor.java:214) 在 org.eclipse.birt.report.engine.executor.ImageItemExecutor.execute(ImageItemExecutor.java:111) 在 org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43) 在 org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46) 在 org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34) 在 org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resumeLayout(HTMLInlineStackingLM.java:111) 在 org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layoutNodes(HTMLInlineStackingLM.java:160) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLTableBandLM.layoutChildren(HTMLTableBandLM.java:67) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLRepeatHeaderLM.layoutChildren(HTMLRepeatHeaderLM.java:46) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resumeLayout(HTMLInlineStackingLM.java:111) 在 org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layoutNodes(HTMLInlineStackingLM.java:160) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) 在 org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) 在 org.eclipse.birt.report.engine.layout.html.HTMLRepeatHeaderLM.layoutChildren(HTMLRepeatHeaderLM.java:46) 在 org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140) 在 org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70) 在 org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92) 在 org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100) 在 org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)

【问题讨论】:

  • 请提供一些您当前正在尝试的源代码,以及异常的完整堆栈跟踪。
  • 嗨弗洛里安,我已经更新了我的帖子,请检查一次。感谢您的关注。

标签: java birt


【解决方案1】:
TextItemHandle nText = designFactory.newTextItem(null);
nText.setContentType(DesignChoiceConstants.TEXT_CONTENT_TYPE_HTML);
nText.setContent("<img src="+ "D:\\***Ws_16-11-18\\com.** (*.***.projectcreation\\icons\\sample.gif" + " />");
contentCell.getContent().add(nText);

这段代码可以让我插入图片

【讨论】:

    猜你喜欢
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 2014-02-28
    • 2019-06-16
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    相关资源
    最近更新 更多