首页 > 编程知识 正文

关于cognosjs调试的信息

时间:2023-12-24 12:05:23 阅读:320181 作者:DWXZ

本文目录一览:

Cognos 用JS实现导出Excel按钮 ?求代码,急!

我用的报表开发工具是FineReport,这种情况出现在FineReport中的解决方案是

1. 描述

FineReport支持多种不同的导出方式,直接使用FineReport内置导出按钮可以非常快捷方便的来对各种格式的输出,但是我们在web页面集成中的时候,往往只想讲报表内容嵌入到iframe中,而工具栏以及工具栏上的按钮都会隐藏掉,而使用web页面自定义的按钮,那么,此时,这种自定义按钮如何实现导出呢,如下图所示:

2. 示例

如上图所示,我们新建一个html页面,定义一个工具栏和一个iframe,工具栏中定义上图所示的按钮,iframe中嵌入FR中的报表,如下图:

2.1 FR报表设置

打开设计器,找到上面web页面中嵌入的那张模板,由于要使用自定义按钮作为工具栏,那么FR报表内置的工具栏就无需显示出来。点击模板模板web属性分页预览设置,去掉使用工具栏前面的勾选,如下图:

2.2 自定义导出按钮

web页面中定义了6个自定义导出按钮,那么怎样才能实现导出操作呢?

FineReport导出操作的js接口为:

导出PDF:exportReportToPDF()

导出[Excel](分页):exportReportToExcel('page')

导出[Excel](原样):exportReportToExcel('simple')

导出[Excel](分页分sheet):exportReportToExcel('sheet')

导出[图片]:exportReportToImage('gif')【括号里面可以更换参数,比如说png,jpg等等图片类型】

导出[word]:exportReportToWord()

故,各个按钮的点击事件应该调用上述的js接口来实现其对应的导出格式,比如说导出PDF,那么其按钮的onclikc事件为:

onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToPDF()"

注:document.getElementById('reportFrame')是获取到iframe框架,然后通过contentWindow得到报表窗口,并拿到contentPane这个报表容器,最后就可以从容器中调用各种导出接口的方法了。

其他的几个按钮的导出事件这里就不一一讲解了。

2.3 完整代码

根据上述同样的方法为其他几个按钮添加导出事件,完整代码如下:

html

head

titleFineReport自定义导出/title

meta http-equiv="Content-Type" content="text/html; charset=GBK" /

/head

body

fieldset

div id="toolbar"

button type="button"  onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToPDF()"导出[PDF]/button

button type="button"  onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToExcel('page')"导出[Excel](分页)/button

button type="button"  onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToExcel('simple')"导出[Excel](原样)/button

button type="button"  onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToExcel('sheet')"导出[Excel](分页分sheet)/button

button type="button"  onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToImage('png')"导出[图片]/button

button type="button"  onclick="document.getElementById('reportFrame').contentWindow.contentPane.exportReportToWord()"导出[Word]/button

/div

/fieldset

iframe id="reportFrame" width="100%" height="100%" src='ReportServer?reportlet=doc/Primary/DetailReport/Details.cpt' /iframe

/body

/html

3. 效果查看

点击不同的按钮,即可看到其导出的结果:

Cognos通过JS设置值提示的默认值

根据需要,设置默认值,并显示对应的列表信息。这里设置为值提示的最后一个值,并去掉值提示中的“------”选项。效果如下:

求助:关于Cognos8打印报表的问题

是打印报表的什么问题呢?在进行报表集成时,常常需要通过js来调用打印事件,在我用的报表软件finereport中就是用的这种方法,在调用之前,需要先引入finereport.js,在通过doURLxxxxPrint()进行调用。

1)doURLxxxxPrint(printurl)

FR.doURLFlashPrint("/WebReport/ReportServer?reportlet=report.cpt")

2)doURLxxxxPrint(printurl,isPopUp)

FR.doURLFlashPrint("/WebReport/ReportServer?reportlet=report.cpt",true);

3)doURLxxxxPrint(config)

var printurl="";     

var reportlets ="[{reportlet: '1.cpt', p1: 'a'}, {reportlet: '1.cpt', p1: 'b'}]";

var config = {

url : printurl,

isPopUp : false,

data : {

reportlets: reportlets

}

};

FR.doURLPDFPrint(config);

cognos custom view 哪里

1.在page页面中加入4个HTLM 项目分别用来实现隐藏工具栏、打印、Excel2002导出、选择导出格式。如下:

2.修改4个HTML属性-》常规-》说明内容分别为:隐藏工具栏、打印、Excel2002导出、选择导出格式。

3.修改完毕。如下所示:

4.隐藏工具栏对应的JS代码:

style .mainHeader1{ display: none;}

.mainViewerHeader3{ display: none;}

/style

5.打印Html对应的js 代码:(打印报表)

input type="button" value="打印" style="padding-left:10px;padding-right:10px;font-size: 10px" onclick="javascript:print();" class="toolbarButton"/

6.Excel2002导出Html对应的JS代码:(Excel2002格式导出报表)

input type="button" value="Excel2002导出" style="padding-left:0px;padding-right:0px;font-size:10px"

onclick="javascript:gCognosViewer.getRV().viewReport('XLWA')"

class="toolbarButton"/

7.选择导出Html对应的JS代码:(下拉框导出不同格式报表)

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"

HTML

HEAD

TITLE New Document /TITLE

META NAME="Generator" CONTENT="EditPlus"

META NAME="Author" CONTENT=""

META NAME="Keywords" CONTENT=""

META NAME="Description" CONTENT=""

script language="javascript"

function Export_js(){

var s;

var se =document.getElementByIdx_x_x("zbsjlx");

var options=se.getElementsByTagName_r("option");

for(var i=0;ioptions.length;++i)

{

if(options[i].selected)

{

s = options[i].text;

}

}

var str=s;

if(str=='Excel2007'){

eval_r(gCognosViewer.getRV().viewReport('spreadsheetML'));

}else if(str=='Excel2003'){

eval_r(gCognosViewer.getRV().viewReport('XLWA'));

}else if(str=='Excel2002'){

eval_r(gCognosViewer.getRV().viewReport('XLWA'));

}else if(str=='Singlesheet'){

eval_r(gCognosViewer.getRV().viewReport('singleXLS'));

}else if(str=='Excel2000'){//Excel2000有可能不支持

eval_r(gCognosViewer.getRV().viewReport('XLS'));

}else if(str=='PDF'){

eval_r(gCognosViewer.getRV().viewReport('PDF'));

}else {

alert('请选择导出格式!');

}

}

/script

/HEAD

BODY

table

TD nowrap class="Edit_content"select id="zbsjlx" name="zbsjlx"

option selected value="Excel2007"Excel2007/option

option value="Excel2003"Excel2003/option

option value="Excel2002"Excel2002/option

option value="Singlesheet"Singlesheet/option

option value="Excel2000"Excel2000/option

option value="PDF"PDF/option

/select

/TD

TD /TD

TD /TD

TD

input type="button" value="导出" onClick="Export_js()" class="toolbarButton"/

/TD

/table

/BODY

/HTML

8.界面实现效果:

请教一个cognos添加js的问题

请问题主到底是添加js的什么问题呢,是需要添加js控件呢还是在运用js语言的时候遇到了困难呢?可以明确的说明一下吗?

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。