本文主要是介绍BIRT报表script,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.隔行高亮显示
1. 在布局(Layout)中,选择Table-Detail的行。如下图:
2. 然后选择Script,打开脚本窗口顶部的方法列表并选择onPrepare,如图所示。
var count=0;
3. 最后打开脚本窗口顶部的方法列表并选择 onCreate,如图所示:
count++;
if (count % 2 != 0) {
style.setBackgroundColor(silver);
}
4. 保存,点击Preview预览结果如下图。
这是网上找别人的案例来的,然后就照着做,就出现问题了
报了一大堆问题:
Multiple annotations found at this line:- org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "count++; if (count % 2 != 0) { style.setBackgroundColor("#000000"); }": ReferenceError: "count" is not defined. (/report/body/grid[@id="43"]/row[@id="45"]/cell[@id="46"]/table[@id="49"]/detail/row[@id="54"]/method[@name="onCreate"]#1) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:249) at org.eclipse.birt.report.engine.script.internal.RowScriptExecutor.handleOnCreate(RowScriptExecutor.java:64) at org.eclipse.birt.report.engine.script.internal.OnCreateScriptVisitor.visitRow(OnCreateScriptVisitor.java:167) at org.eclipse.birt.report.engine.ir.RowDesign.accept(RowDesign.java:108) at org.eclipse.birt.report.engine.script.internal.OnCreateScriptVisitor.onCreate(OnCreateScriptVisitor.java:73) at org.eclipse.birt.report.engine.executor.ReportItemExecutor.handleOnCreate(ReportItemExecutor.java:917) at org.eclipse.birt.report.engine.executor.RowExecutor.execute(RowExecutor.java:83) at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46) at org.eclipse.birt.report.engine.internal.executor.emitter.ReportItemEmitterExecutor.execute(ReportItemEmitterExecutor.java:46) at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43) at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46) at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34) at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65) at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26) at
.
.
.
ReferenceError: "count" is not defined表示说我的count未定义,我不是明明定义了吗。
又到网上搜了,然后就说:
不是在明细行的script里定义count,定义count也不能使用var哦。
要在表格的onprepare里定义count=0;
貌似在明细里还是在表格的script定义都一样,然后把它修整过来,竟然可以了。
这篇关于BIRT报表script的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!