The report is an important part of Web-based OA. I have experienced three phases.
The earliest is to output the report directly in IE, which is a way to make a report. This is logically simple
single. It is just that the customer is not very convenient when using it. Because some report output results, customers need to modify, such as deleting
In addition to some lines, some columns. To this end, I wrote a long code with JavaScript for custom output.
Columns, output different columns based on his choice. As for some customers to delete some rows. I suggest that customers will lose IE
The report is all copied to ELXCEL, and edit printing there.
Do a report with Ireport.
Learn to write the IERPORT to do a report, I spent a week. This is indeed a good report tool. I must make some reason
Use JDK1.3.1 so IREPORT0.1.0 that is better but the compatibility but the version is compared. But encounter some questions
question. For example, in the IREPORT, the form is used in line tools. There are various Bands on the design layout, each Band is planned
Divided a certain location. If I am in a region, such as the line painted in Column header, I am not careful to get out of Detail.
In the report, the vertical line cannot be output when the report is compiled and output, so I think the form is not too square in Ireport.
Convenient. I also doubt whether I used the tool version too low? There is also a problem with Ireport, the client needs
Adobe Acrbat Reader can only see the report. I want to use Ireport to make a cookie histogram, and I have not succeeded.
Call the IREPORT with a JSP file. Jasper file always pops up the dialog asks if it is opened or downloaded, I am chaos after I open it.
Code, it is also garbled after downloading. It is said that it is an Adobe Reader, and it is not changed from IE and Adobe Reader.
Row, depressed ing.
Use the servlet call .jasper file. It's still not working with Adobe Reader6.0, it may be that my jsper.jar version is too low, it is changed.
Adobe Reader 4.0 is successful. Specific example
JSP call: Test.jsp file
<% @ Page import = "DORI.JASPER.EENGINE. *"%>
<% @ Page Import = "java.util. *"%>
<% @ Page Import = "java.io. *"%>
<% @ Page Import = "java.sql. *"%>
<%
Java.sql.connection sqlcon; // Database connection object
Java.lang.String strcon; // Database connection string
// Load JDBC driver
Class.Forname ("com.microsoft.jdbc.sqlser.sqlserverdriver);
/ / Set the database connection string
Strcon = "JDBC: Microsoft: SQLSERVER: // localhost: 1433; DatabaseName = Kenoah";
//Connect to the database
Sqlcon = java.sql.driverManager.getConnection (StrCon, "SA", "SA");
File ReportFile = New File (Application.getRealPath ("/ Reports / Test1.jasper");
Out.println (ReportFile.getPath ());
Out.println (SQLCON);
Map parameters = new hashmap ();
Parameters.put ("ReportTitle", "P"); byte [] bytes = jasperrunmanager.runreporttopdf (
Reportfile.getPath (),
Parameters,
Sqlcon
);
Out.println (Bytes.length);
Response.setContentType ("Application / PDF");
Response.setContentLength; Bytes.length
ServletOutputStream OuputStream = response.getOutputStream ();
OuputStream.write (bytes, 0, bytes.length);
Ouputstream.flush ();
Ouputstream.close ();
%>
Servlet call: Testreport.java
Import javax.servlet. *;
Import javax.servlet.http. *;
Import dori.jasper.Engine. *;
Import java.io. *;
Import java.util. *;
Import java.sql. *;
Public Class TestReport Extends httpservlet {
Public void doget (httpservletRequest request, httpservletResponse response) throws servletexception, ioException {
Connection conn = NULL;
Try {
Class.Forname ("com.microsoft.jdbc.sqlser.sqlserverdriver);
Conn = drivermanager.getConnection ("JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = Kenoah", "SA", "SA");
ServletContext servletcontext = this.getServletContext ();
File ReportFile = New File (servletContext.getRealPath ("/ report / test1.jasper"));
Map parameters = new hashmap ();
String MyName = New String ("lxd");
Parameters.Put ("Name", MyName);
System.out.println (MyName);
System.out.Println ("Hello");
Byte [] bytes = jasperrunmanager.runreporttopdf (ReportFile.getPath (), parameters, conn;
Response.setContentType ("Application / PDF");
Response.setContentLength; Bytes.length;
ServletOutputStream outputStream = response.getOutputStream ();
OutputStream.write (bytes, 0, bytes.length);
OutputStream.flush ();
OutputStream.Close ();
} catch (jrexception jre) {
System.out.println ("JREXCEPTION:" JRE.GETMESSAGE ());} catch (Exception E) {
System.out.println ("Exception:" E.getMessage ());
}
}
Public void dopost (httpservletRequest request, httpservletResponse response) throws servletexception, ioException {
DOGET (Request, Response);
}
}
Export the report directly to Word
I think this is a good way to use the Web way OA. Simple production, just modify the original JSP file,
Put the output mode to call Word.
Then the output report calls Word directly, runs out if you pop up the dialog box to ask if you open or save it, choose Open, IE calls Word directly,
That customer can edit the output report directly in Word.
JSP file modified place: <% @ page contenttype = "Application / MSWORD; charset = GB2312"%> is the value of the ContentType.
Example: mytest.jsp
<% @ Page ContentType = "Application / Msword; Charset = GB2312"%>
<% @ Page Import = "java.sql. *"%>
HEAD>