BIRT report script, birtscript
1. line separation highlighted
1. in Layout, select the rows of Table-Detail. For example:
2. Select Script, open the method list at the top of the Script window, and select onPrepare ,.
Var count = 0;
3. Open the method list at the top of the script window and select onCreate ,:
Count ++;
If (count % 2! = 0 ){
Style. setBackgroundColor (silver );
}
4. Save and Click Preview to Preview the result, as shown in.
This is the case of finding someone else online. Then, the problem occurs.
A lot of problems were reported:
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 indicates that my count is not defined. Isn't it clearly defined.
I searched the internet and then said:
Instead of defining count in the script of the line details, defining count cannot use var.
Define count = 0 in onprepare of the table;
It seems that the definition of the script in the table is the same in the details, and then it can be trimmed.