JXL writing data from an HTML form to Excel

Source: Internet
Author: User

First download the Jxl-2.6.12.jar or add it in Maven

<dependency> <groupId>net.sourceforge.jexcelapi</groupId> <artifactid>jxl</artifa Ctid> <version>2.6.12</version> </dependency>


The background code is as follows:

  writableworkbook wwb = null;  wwb=workbook.createworkbook (New File (" C:\\1.xls "));//Create Excel file     writablesheet ws = wwb.createsheet (" Sheet1 ", &NBSP;0);//Create a writable worksheet         ws.setcolumnview (11,30);//Set the width of the column    ws.setcolumnview (0,25);   ws.setcolumnview (6,20);   ws.setcolumnview (9,20);   //Set Header   ws.addcell (New label (0,0, "product picture"));   ws.addcell (New label (1, 0, "Product name   ws.addcell (New label (2,0, "market price")),   ws.addcell (New label (3,0, "member Price"));   ws.addcell (New label (4,0, "the person under test");   ws.addcell (New label (5,0, "status"));   ws.addcell (New label (6,0, "Sample Time"))   ws.addcell (New label (7,0, "recipient");   Ws.addcell (New label (8,0, "logistic number"))   ws.addcell (New label (9,0, "Reporting time");   Ws.addcell (New label (10,0, "logistic number"));   ws.addcell (New label (11,0, "test Report");     //add row data to traverse collection data that needs to be written to Excel    for  (Int i=1;i<=odvs.size (); i++) {   orderdetailvo row=odvs.get (i-1);    system.out.println (row);      ws.addcell (New Label (0,i, Row.getthumbnail ()));     ws.addcell (New label (1,i,row.getname ()));     ws.addcell (New label (2,i,row.getmarketprice (). toString ()));     ws.addcell (new  label (3,i,row.getmemberprice (). toString ()));     ws.addcell (New label (4,i, Row.getpersonname ()));     ws.addcell (New label (5,i,row.getstatus ()));     ws.addcell (New label (6,i,row.getrecieveorderdate (). toString ()));     Ws.addcell (New label (7,i,row.getcontact ()))     ws.addcell (New Label (8,i, Row.getreceivetracknumber ()));    ws.addcell (New label (9,i,row.getreportsenddate (). toString ()));     ws.addcell ( New label (10,i,row.getreporttracknumber ()));     ws.addcell (New Label (11,i, Row.getreportdownloadpath ()));        }                wwb.write ();//write Files from memory               wwb.close ();  //close resource, free memory

The converted 1.xls document is as follows

650) this.width=650; "title=" capture. PNG "alt=" wkiol1w8ev_spjzhaak68tnkw0e682.jpg "src=" http://s3.51cto.com/wyfs02/M00/70/BE/wKioL1W8ev_ Spjzhaak68tnkw0e682.jpg "/>

Reference article:

http://pengfeicao521.iteye.com/blog/1415699


This article is from the "Nothing-skywalker" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1680812

JXL writing data from an HTML form to Excel

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.