Monday, 13 October 2014

Java Script to export cognos report into Excel & PDF

 

    Export Cognos Report into Excel and PDF   using Java script.

 

Requirement:  User wants a Button to Export Report HTML output into Excel & PDF both on a click.
Solution: Using HTML Items and Java scripting this can be achieved.

Put two HTML Items in the report where you want to create Export Button.

Copy the below mentioned code and paste into HTML items accordingly.

Script for HTML 1:
<SCRIPT>
<!--
function reRunExcel(){
//while Running report
Try
{
oCV_NS_.getRV().viewReport('spreadsheetML');
}
catch(err) {}
//while Testing report
try
{
oCVRS.getRV().viewReport('spreadsheetML');
}
catch(err) {}
}
//-->
</SCRIPT>
<A href="javascript:reRunExcel();"> </a>

Script for HTML 2:
<html>
<head>
<script language="javascript">
function gotourl()
{var obj=document.all['OutputFormat'];
var value="PDF";
window.onload(gCognosViewer.getRV().viewReport (value));
function reRunExcel(){
//while Running report
try
{
oCV_NS_.getRV().viewReport('spreadsheetML');
}
catch(err) {}
}
}
</script>
</head>
<body>
</body>
<button onclick="gotourl(); reRunExcel();">Export to Excel/PDF </Button>

On running this report you will get a Button to Export report into Excel & PDF.


10 comments:

  1. 243DF13DC2Tony8D01CC9D9712 October 2024 at 11:01

    38BF8B9E2F
    güvenilir show

    ReplyDelete