JSP export the table from the webpage to excel

Source: Internet
Author: User

1. Display webpage data in an Excel report in the form of online browsing

<% @ Page contenttype = "application/MSExcel" %> <br/> <! -- In the preceding line, set this webpage to an Excel webpage --> <br/> <% <br/> response. setheader ("content-disposition", "inline; filename=test1.xls"); <br/> // test1.xls is the file used for transferring data to the browser. <br/> // This line is used, enable the front-end browser to receive an Excel file <br/>%> <br/> <HTML> <br/> <pead> <br/> <title> Excel file presentation mode </title> <br/> </pead> <br/> <body> <br/> <Table border = "1" width = "100%"> <br/> <tr> <br/> <TD> name </TD> <TD> ID card size </TD> <TD> birthday </TD> <br/> </tr> <br/> <tr> <br/> <TD> Li Yun </TD> <TD> n111111111 </TD> <TD> 1900/11/12 </TD> <br/> </tr> <br/> <TD> Liang jingru </TD> <TD> n222222222 </TD> <TD> 1923/10/1 </TD> <br/> </tr> <br/> <TD> Zhang huimei </TD> <TD> n333333333 </TD> <TD> 1934/12/18 </ TD> <br/> </tr> <br/> </table> <br/> </body> <br/> </ptml>
2. Use an Excel report to download and present webpage Materials
This JSP file is similar to the previous one. Only the difference lies in this line:
Online browsing: Response. setheader ("content-disposition", "inline; filename=test1.xls ");
Download Method: Response. setheader ("content-disposition", "attachment; filename=test2.xls ");
Note: 1. the Excel files are displayed only on static Web pages. With the help of the database, you can use dynamic reports to make EXCEL reports.
2. There is no need to install any components at all, or it can only be restricted to the win platform. A simple solution to your report needs
3. If you are smart, you should be able to show your website information in Word doc format!
(Do you only need to change contenttype to "application/MSWord" and the filename's subdocument name to .doc !)
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.