示例说明
在透视分析报表的第一行参数最后添加“分析”按钮,点击“分析”则刷新报表,在第二行参数后面添加“导出”按钮,点击“导出”,则导出excel。
具体实现效果见下图:
设置方法
- 在“分析展现”节点下,创建一张透视分析。
选中透视分析,右键选择 编辑宏 进入报表宏界面。
注意:该透视分析要求参数分两列。- 在报表宏界面新建客户端模块,在弹出的新建模块对话框中选择对象为INSIGHT;事件为onRender;并把下面宏代码复制到代码区域。
宏类型
类型 | 对象 | 事件 |
---|---|---|
ClientSide | INSIGHT | onRender |
宏代码
代码块 | ||||||
---|---|---|---|---|---|---|
| ||||||
function main(insight) {
if (typeof(insight.old_rebuildParamPanel) == "undefined") {
insight.old_rebuildParamPanel = insight.rebuildParamPanel;
insight.rebuildParamPanel = function() {
this.old_rebuildParamPanel();
addBtns(this);
};
}
}
//添加按钮
function addBtns(insight) {
var paramTable = insight.paramPanelObj.layoutTable;
var i, cell, lastCell1, lastCell2;
for (i = 0; i < paramTable.rows.length; i++) {
cell = paramTable.rows[i].insertCell(-1);
if (i == 0) lastCell1 = cell; //paramTable.rows.length - 1
if (i == 1) lastCell2 = cell;
}
//添加分析按钮
if (lastCell1) {
var btnElem = document.createElement("button");
btnElem.innerText = "分析";
btnElem.className = "queryview-toolbar-button";
btnElem.style.border = "1px solid #A1ACB9";
btnElem.style.width = "60px";
btnElem.style.height = "23px";
btnElem.style.padding = "2px 0 0 0";
btnElem.style.margin = "0 10px 0 10px";
insight.addListener(btnElem, 'click',
function() {
insight.doRefresh();
}, this);
lastCell1.appendChild(btnElem);
}
//添加导出按钮
if (lastCell2) {
var btnExport = document.createElement("button");
btnExport.innerText = "导出";
btnExport.className = "queryview-toolbar-button";
btnExport.style.border = "1px solid #A1ACB9";
btnExport.style.width = "60px";
btnExport.style.height = "23px";
btnExport.style.padding = "2px 0 0 0";
btnExport.style.margin = "0 10px 0 10px";
insight.addListener(btnExport, "click",
function() {
insight.doExportMenuCloseUp("EXCEL2007");
}, this);
lastCell2.appendChild(btnExport);
}
} |
资源下载
资源:migrate.xml
borderColor | #BBBBBB |
---|---|
bgColor | #F0F0F0 |
borderWidth | 1 |
borderStyle | solid |