Jsp implements the printing method for excel and Word documents, jspexcel

Source: Internet
Author: User

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.

Related Article

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.