注意 | ||
---|---|---|
| ||
本文档的示例代码仅适用于本文档中的示例报表/场景。若实际报表/场景与示例代码无法完全适配(如使用功能不一致,或多个宏代码冲突等),需根据实际需求开发代码。 |
示例说明
在组合分析中获取表中的内容生成动态标题,并给动态标题写样式,如下图:
设置方法
- 在资源定制节点下,创建一张组合分析。
- 选中组合分析,右键选择 编辑宏 进入报表宏界面。
- 在报表宏界面新建客户端模块。在弹出的新建模块对话框中选择对象为simpleReport、事件为onRenderTable、并把下面宏代码复制到代码区域;
宏类型
类型 | 对象 | 事件 |
ClientSide | simpleReport | onRenderTable |
宏代码
代码块 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
function main(simpleReport, simpleReportContext) { var tailHTML; var c1 = simpleReport.grid.getCell(1, 1); var c2 = simpleReport.grid.getCell(1, 2); var c3 = simpleReport.grid.getCell(1, 3); tailHTML = "<font style='font-weight:bold; font-size:18px; color:#000'>组分析标题宏</font><font style='font-size:12px; color:#000'>销售额:<font style='font-size:12px; color:#00F'>" + c1.innerHTML + "</font>元 销售量:<font style='font-size:12px; color:#FC0'>" + c2.innerHTML + "</font>箱 运费:<font style='font-size:12px; color:#F00'> " + c3.innerHTML + "</font>元</font>"; simpleReport.setHeader(tailHTML); } |
...
- 设置单元格显示值:simpleReport.grid.setCellText(int,int,text)
...