
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Export to excel functionality
Hi ,I have developed a JSP Report IN ppm 9.1.I wanted to use export to excel functionality but somehow my code is not working.Could anyone tell me the code for same


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Create a hyperlink in report to a new JSP file.
Now create a new JSP file like this....
<%@ page contentType="application/vnd.ms-excel" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ page language="java" import="java.util.*"%>
<%@ page import="java.net.*"%>
<%@ page import="java.io.*"%>
<%
/*String strReportNumber = request.getParameter("REPORT_ID"); // below I have hardcoded this.. you // can use this code to make it // generic
String strName = "/itg/reports/rep_"+strReportNumber+".html";*/
try{
String strName = "<PPM_ROOT>/reports/rep_62754.html";
String thisLine;
String lName = "ExportToExcel";
int lindexflag = 0 ;
FileInputStream fin = new FileInputStream(strName);
BufferedReader myInput = new BufferedReader
(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null)
{
lindexflag = thisLine.indexOf(lName);
if(lindexflag <= 0)
{
out.println(thisLine);
}
}
fin.close();
}
catch(Exception e){out.println(e);}
%>
Utkarsh Mishra
-- Remember to give Kudos to answers! (click the KUDOS star)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Im getting below mentioned error
I'm sorry, we were unable to find the page you requested.
The page you requested does not seem to exist. There are some common reasons you might get this error.If you typed the URL directly into the address field it is easy to mistype a page name or path. Please quickly verify you typed in the address you intended.Sometimes when you follow a URL from an email, the mail reader has accidentally broken up the URL into pieces. This means the browser has not received the full URL. An easy way to fix this is to select the full URL in the email, copy it, and paste it into the browser address field.If neither of these situations has occurred, please take note of the page URL and notify your Administrator that you received a HTTP 404 error. It could be the result of a problem with the configuration.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Try to give correct path of report directory, where the reports HTML is saved in PPM.
This is handled here by:
String strName = "/itg/reports/rep_"+strReportNumber+".html"
you need to modify this to coorect path as per your configuration.
Utkarsh Mishra
-- Remember to give Kudos to answers! (click the KUDOS star)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
path is like
/ppmtst01/ppmtst/reports
but still its not working .Same error i am getting.code is given below :-
<%@ page contentType="application/vnd.ms-excel" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ page language="java" import="java.util.*"%>
<%@ page import="java.net.*"%>
<%@ page import="java.io.*"%>
<%
String strReportNumber = request.getParameter("REPORT_ID"); // below I have hardcoded this.. you // can use this code to make it // generic
String strName = "/ppmtst01/ppmtst/reports/rep_"+strReportNumber+".html";
try{
String strName = "/ppmtst01/ppmtst/reports/rep_"+strReportNumber+".html";
String thisLine;
String lName = "ExportToExcel";
int lindexflag = 0 ;
FileInputStream fin = new FileInputStream(strName);
BufferedReader myInput = new BufferedReader
(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null)
{
lindexflag = thisLine.indexOf(lName);
if(lindexflag <= 0)
{
out.println(thisLine);
}
}
fin.close();
}
catch(Exception e){out.println(e);}
%>


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Try to hard-code any report number instead of Report_ID.
Make sure the path is correct i.e. you are able to access that html report.
Utkarsh Mishra
-- Remember to give Kudos to answers! (click the KUDOS star)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Try to use below peice of code:
<script type="text/javascript">
function export_to_excel()
{
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE");
if (msie > 0 || navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer
{
txtArea1.document.open("txt/html","replace");
txtArea1.document.write(document.documentElement.outerHTML);
txtArea1.document.close();
txtArea1.focus();
return (txtArea1.document.execCommand("SaveAs",true,"rep_" + <c:out value="${REPORT_ID}"/> + ".xls"));
}
else //other browsers
{
var link = document.createElement('a');
link.download = "rep_" + <c:out value="${REPORT_ID}"/> + ".xls";
link.href = 'data:application/vnd.ms-excel,' + encodeURIComponent(document.documentElement.outerHTML);
link.click();
//return(window.open('data:application/vnd.ms-excel,' + encodeURIComponent(document.documentElement.outerHTML)));
}
}
</script>
<iframe id="txtArea1" style="display:none"></iframe>
<a href="#" onclick="export_to_excel();">Export to Excel</a>
Regards,
Shiwan