Absent Member.
Absent Member.
1029 views

Export to excel functional​ity

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

0 Likes
6 Replies
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

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);}

 

%>

 

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
Absent Member.
Absent Member.

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.

0 Likes
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

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.

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
0 Likes
Absent Member.
Absent Member.

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);}

 

%>

0 Likes
Cadet 2nd Class Cadet 2nd Class
Cadet 2nd Class

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.

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
0 Likes
Cadet 1st Class Cadet 1st Class
Cadet 1st Class

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&colon;application/vnd.ms-excel,' + encodeURIComponent(document.documentElement.outerHTML);
                        link.click();
      //return(window.open('data&colon;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

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.