In the customer's application there is usually a situation, the report is displayed by their own original program implementation, use of drying is only used in the report printing and export. Or on a page to select the query criteria and the name of the report, select the completion of a direct click on the Print or export button to achieve the table printing or export operations, drying can meet the requirements, but to make the relevant changes to the page, the implementation method is as follows:
Run-dry built-in a few printed or exported JS functions, such as Report1_print (), Report1_saveasexcel () and other functions, but if you use these functions, you must show the report on the page before the line, the customer asked not to show the report, Here you can define the JS function to implement related functions.
1, add the Print Export button on the page, such as:
<a href= "#" onclick= "Excel (); return false;" > Export excel</a>
<a href= "#" onclick= "word (); return false;" > Export word</a>
<a href= "#" onclick= "print (); return false;" > Printing </a>
So the click on the page on the related action is actually called the JS method.
2. Parameter passing
In the customer system, there are usually some parameters to the data filtering, so that when printed or exported to the report of the parameter to the calculation, run dry in the printing and export the parameter value is mainly through the parameter cache ID, that is REPORTPARAMSID
So to convert the customer's parameters into Reportparamsid, the code is as follows:
String raqname= "Ppp.raq";//Report name, then change to the Cadre appointment and dismissal form
String reportparamsid = null;//definition Reportparamsid
Hashtable hash = new Hashtable ();
Hash.put ("Arg1″," 1111111″);//The parameters and values are placed in Hashtable, arg1 as the parameters defined in the report, the CIRC is changed to the person ID that parameter name, 111111 is the parameter value, the UserID is placed in this
if (hash.size () > 0) {
Generate an ID and set the key value relationship between this ID and the hash you just prepared
Reportparamsid = Com.runqian.report4.view.ParamsPool.createParamsId ();//generate parameter Cache ID
Com.runqian.report4.view.ParamsPool.put (Reportparamsid, hash);//Put the ID in the cache
}
System.out.println ("reportparamsid=" +reportparamsid);
This generates a cache ID that can be passed to the report server to participate in the calculation
3, JS function writing
As mentioned earlier, when the button is clicked on the page, the JS function is actually called, so the JS function is implemented in the page.
<script language=javascript>
function print () {
Document.report1_printIFrame.location = "http://127.0.0.1:6002/demo/reportservlet?action=2&name=report1& Reportfilename=<%=raqname%>&srctype=file&saveprintsetup=yes&appletjarname= Runqianreport4applet.jar&serverpagedprint=no&mirror=no&reportparamsid=<%=reportparamsid%> ";
}
function Excel () {
Document.report1_saveAs_frame.location = "http://127.0.0.1:6002/demo/reportServlet?action=3&file=<%= Raqname%>&columns=0&srctype=file&width=-1&height=-1&reportparamsid=<%=reportparamsid %> "
}
function Word () {
Document.report1_saveAs_frame.location = "http://127.0.0.1:6002/demo/reportServlet?action=7&file=<%= Raqname%>&columns=0&srctype=file&reportparamsid=<%=reportparamsid%> ";
}
</script>
Finally, due to the use of Report1_saveas_frame and report1_printiframe when printing or exporting, in order to avoid JS errors, add in the page:
<iframe name= "Report1_saveas_frame" id= "Report1_saveas_frame" src= "a.html" style= "Display:none" ></iframe >
<iframe name= "Report1_printiframe" id= "Report1_printiframe" src= "a.html" style= "position:absolute;left:-100px; top:-100px "Width=50 height=50></iframe>
This will enable the report to be displayed, click the relevant button after the print or export operation.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.