jexcel+struts2 implementation upload Download, that is, model data exported to Excel format and upload files in Excel format

Source: Internet
Author: User

3. Query out the data, first define the column number of the header and table header, convert the properties of each object to a string[], and then deposit all the converted string[] into list<string[]>, and jexcel the header string[ ] and list<string[]> loop through, converting each substring into a cell in Excel, writing it out into the output stream, and finally converting the output stream to an input stream to return to the download view. Finally, the following methods are presented when the page is accessed. The download view is configured by the Struts.xml., the download view does not jump to the page, after the page click the Download button, after sending the request after the data processing, and finally directly return to the type= "stream" Download view, for file download, the page appears as a click button after the Save prompt box. At the same time, the MIME type of contenttype Zodiac can be found from the Config directory in Tomcat from Web. Xml.

The upload process is done by jexcel the local Excel file after it is read, followed by a row for one object, read as a list<string[]), and then set the string in each row of string[] to each property of an object. Finally, the list <String[]> into a collection of list<employee>.

jexcel+struts2 implementation upload Download, that is, model data exported to Excel format and upload files in Excel format

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.