API Read Report template add Print button

Source: Internet
Author: User

Background notes

After the API reads the report template, it is easy to send the code to the corresponding document, such as the page presentation and export to Word, by operation. If the user wants the code after the operation, through the applet to print, this function how to implement it, how to add this Print button. Let's look at an example.

Application examples

Create a new JSP page with the following code:

<%@ page contenttype= "text/html;charset=gb2312"%>

<%@ page import= "java.io.*"%>

<%@ page import= "com.runqian.report4.usermodel.*"%>

<%@ page import= "com.runqian.report4.model.*"%>

<%@ page import= "com.runqian.report4.view.html.*"%>

<%@ page import= "com.runqian.report4.util.*"%>

<%@ page import= "com.runqian.report4.view.excel.*"%>

<%

The first step is to read the report template

InputStream Fis=application.getresourceasstream ("/reportfiles/test.raq");

Reportdefine rd = (reportdefine) reportutils.read (FIS);

The second step, the Operation report

Context context = new context ();

Engine enging = new engine (rd, context);

IReport IReport = Enging.calc ();

Fourth step, show (show with pagination results)

Htmlreport hreport = new Htmlreport (IReport, "Report1");

Out.print (hreport.generatehtml ());

%>

<a href= "#" onclick= "Report1_print (); return false;" >print</a>

<script language=javascript>

function Report1_print () {

Document.report1_printIFrame.location = "Http://192.168.0.132:8080/second/reportServlet?action=2&name= Report1&reportfilename=test.raq&srctype=file&saveprintsetup=no&appletjarname= Runqianreport4applet.jar&serverpagedprint=no ";

}

</script>

<iframe name= "Report1_printiframe" id= "Report1_printiframe" src= "a.html" style= "position:absolute;left:-100px; top:-100px "Width=50 height=50></iframe>

In this way, when the report is accessed, the page will come out with a print button and the applet can be printed by clicking on it.

http://192.168.0.132:8080/second/reportservlet?action=2&name=report1&reportfilename=test.raq& Srctype=file&saveprintsetup=no&appletjarname=runqianreport4applet.jar&serverpagedprint= No this string should be modified according to the corresponding application.

Http://192.168.0.132:8080/second: Is the ip+ port + application name;

Name=report1 here with the new Htmlreport (IReport, "Report1");

Reportfilename=test.raq here to be the same as Application.getresourceasstream ("/reportfiles/test.raq") in the file name.


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.