JSP implementation for Excel and Word document printing method _jsp programming

Source: Internet
Author: User
Tags odbc stmt

This article describes the JSP implementation of Excel and Word document printing methods. Share to everyone for your reference, specific as follows:

Because MS Word and Excel documents support HTML text formatting, you can use Word or Excel to do the template, save as a Web page, and then change the HTML into a JSP, the data part of the dynamic fill can be, do not have to work hard to adjust the format

The word page simply sets the following instruction in the JSP header:

Copy Code code as follows:
<% @page contenttype= "APPLICATION/MSWORD;CHARSET=GBK"%>

Excel is as follows:
Copy Code code as follows:
<% @page contenttype= "APPLICATION/VND.MS-EXCEL;CHARSET=GBK"%>

In this way the client must have Office software installed and the page will be opened directly in IE with Word or Excel when the user accesses it.

This method advantage is the template design, the adjustment is convenient, does not need to use the complex poi or the JXL technology on the server side, also does not need to use the ActiveX control technology in the client, is more safe, convenient, easy to achieve the good printing effect.

Microsoft information about server-side dynamic creation of Office documents (ASP example):

http://support.microsoft.com/default.aspx?scid=kb;en-us;301044&

Simple example:

Use Word to create a document, drawing the following table:

----------------------------
| User name | Real name | sex |
----------------------------
| Guest | Passerby A | Male |
----------------------------

Save as a Web page test.htm, test.htm renamed to Test.jsp, modify the guest, passers-by a, male from the database dynamic query, as follows:

<%@ page contenttype= "APPLICATION/MSWORD;CHARSET=GBK"%> <%@ page import= "java.sql.*"%>  

I hope this article will help you with JSP programming.

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.