
Lesson 4: Exporting a report set from JSP
You have been asked to run EmployeeInformation.cls from the Sales Order application and allow the user to choose the format of the report. The allowable formats are: PDF, Excel, RTF (Microsoft Word), HTML, Text, PostScript, and XML.
In this lesson you again use DHTML API to run the report set; however, we will use the One Step Export feature to export the DHTML report set in the specified format without displaying it in a separate web browser window.
Task 1: Review the JSP file to run the report set
The JSP page that runs the report set is provided as part of the lesson. Follow these steps to review the JSP code:
- Copy exportReport.jsp in
<install_root>\Demo\source to <install_root>\public_html\jag.
- Open exportReport.jsp in your favorite editor.
<%@ taglib uri="../dhtmljsp/Jinfonet_DHTML_taglib.tld" prefix="jinfonet" %>
<%@ page import="jet.rptservice.api.EngineConstant"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Export Report to user selected format</title>
<script language="JavaScript">
<!--
function exportit(){
var type = document.getElementById("format").value;
var optionValues = new Array();
if(document.getElementById("isExcport").checked){
user_oneStepExport(type, optionValues); // for one step exporting
}else{
user_downloadReport(type, optionValues); // for one step downloading
}
}
//-->
</script>
</head>
<body>
<jinfonet:dhtml
id="report1"
tagsetid="export"
report ="/USERFOLDERPATH/admin/JinfonetGourmetJava/EmployeeInformation.cls"
catalog ="/USERFOLDERPATH/admin/JinfonetGourmetJava/JinfonetGourmetJava.cat"
report_params ="jrs.cmd=jrs.try_vw">
<label>Format:</label>
<select name="ty" size="1" id="format">
<option value="<%=EngineConstant.EXPORT_TYPE_HTML%>" >HTML</option>
<option value="<%=EngineConstant.EXPORT_TYPE_PDF%>" selected>PDF</option>
<option value="<%=EngineConstant.EXPORT_TYPE_XLS%>">Excel</option>
<option value="<%=EngineConstant.EXPORT_TYPE_TEXT%>" >Text</option>
<option value="<%=EngineConstant.EXPORT_TYPE_RTF%>" >RTF</option>
<option value="<%=EngineConstant.EXPORT_TYPE_XML%>">XML</option>
<option value="<%=EngineConstant.EXPORT_TYPE_PS%>" >PostScript</option>
</select>
<br><br>
<label><input id="isExcport" name="isExport" type="radio" value="true" checked>View the result</label>
<label><input name="isExport" type="radio" value="false">Download</label>
to file system <br>
<br>
<input type="button" value="Export" onClick="exportit();">
</jinfonet:dhtml>
</body>
</html>
|
Note: The result types are: 0- HTML, 2 - PDF, 3 - Postscript, 4 - RTF, 5 - TEXT, 6 - Excel, 7 - XML.
Task 2: Export the report result
- Browse http://localhost:8888/jag/exportReport.jsp.
- Choose the desired export format and whether you want to download the result or view it now.
- Click Export to generate the exported report.
The report displays according to the format provided. For downloaded result, use the program on your system to view the results, such as Acrobat Reader or Microsoft Word.
Lesson 4 summary
In this lesson you have learned how to use JSP and DHTML API to run a report set and export the current report in this report set to any format.
