Jsp implements the printing method for excel and Word documents, jspexcel
This document describes how to print excel and Word documents in jsp. We will share this with you for your reference. The details are as follows:
Because documents in ms word and excel support html text format, you can use word or excel to make a template, save it as a Web page, change the html to jsp, and enter the data part dynamically, no need to adjust the format
On the word page, you only need to set the following commands in the jsp header:
Copy codeThe Code is as follows: <% @ page contentType = "application/msword; charset = GBK" %>
Excel is as follows:
Copy codeThe Code is as follows: <% @ page contentType = "application/vnd. ms-excel; charset = GBK" %>
In this way, the client must have the office software installed. When you access the client, you can directly open the page in word or excel in ie.
The advantage of this method is that it is easy to design and adjust templates. You do not need to use complicated POI or jxl technology on the server side, or use ActiveX Control Technology on the client side, which is safer and more convenient, easy to achieve better printing results.
Microsoft documents on Dynamically creating an office on the server (asp example ):
Http://support.microsoft.com/default.aspx? Scid = KB; en-us; 301044 &
Simple Example:
Use word to create a document, as shown in the following table:
----------------------------
| User name | real name | gender |
----------------------------
| Guest | passer-by | male |
----------------------------
Save test.htm as the webpage, and change test.htm to test. jsp. Change guest, passer-by, and male to dynamically query data from the database, as shown below:
<% @ Page contentType = "application/msword; charset = GBK" %> <% @ page import = "java. SQL. * "%>
I hope this article will help you with JSP program design.