Export data from JSP page to Excel table, this content is for reference only. (The "Graduate Information Inquiry" project written during the junior year training)
1. Generate Excel template
1) Create a new Excel file (template.xls) by yourself, enter a record, and then set the font style. As shown in the figure:
Export data from Jsp page to Excel table
2) Save the Excel file as a web page ("File" —> "Save as web page")
Export data from Jsp page to Excel table
3) Use Notepad or UE to open the template .htm, you can see the source code (the source file is relatively long and is omitted here)
2. Generate a Jsp page and make a little modification
note:
1) The green code needs to be written by yourself, in which you need to modify the contentType attribute to application/vnd.ms-excel, and the encoding method to gb2312 to prevent garbled codes)
2) The red code should be written according to your own needs, such as which classes to import and what content to output
3) The rest of the code is the source code of the copied template .htm, in which the yellow code needs to be modified (add "" or ’’ to some of the attribute values)
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.