Export more than 0.2 million data in a sheet in Excel

Source: Internet
Author: User

1. reference the poi package.

Http://download.csdn.net/detail/bucce/4356293

2. Export program modification.

Fileinputstream file = NULL;
Outputstream out = NULL;
Workbook WB = NULL;
Sheet sheet = NULL;

WB = new sxssfworkbooks (1000 );

Sheet = WB. createsheet ("csdaa010 ");

Int start = 0;
Int Limit = 60000;
Boolean B = true;
While (B)
{

Selectsetbiitirannmodel. setstart (start );
Selectsetbiitirannmodel. setlimit (Limit );
Long stimee = java. util. Calendar. getinstance (). gettimeinmillis ();
List <sda_va_daicho_a> kenngla kusetubidaitixyoukannri = itiranservice. kenngkusetubidaitixyoukannria (selectsetbiitirannmodel );

Double DB = double. parsedouble (Java. util. Calendar. getinstance (). gettimeinmillis ()-stimee) + "") * 0.001;
System. out. println ("th" + IE + "------------" + double. parsedouble (Java. util. calendar. getinstance (). gettimeinmillis ()-stimee) + "") * 0.001 + "second"); ie ++;

If (kenngkusetubidaitixyoukannri. Size () <limit)
{
B = false;
} Else
{
Start + = limit;
}

}

Response. setcontenttype ("application/octet-stream ");
Response. setheader ("content-disposition", "attachment; filename =" + outname );
Out = response. getoutputstream ();
WB. Write (out );

Third: style code

// =
Cellstyle styletb1 = WB. createcellstyle ();
Styletb1.setborderbottom (cellstyle. border_thin );
Styletb1.setbottombordercolor (indexedcolors. Black. getindex ());
Styletb1.setbordertop (cellstyle. border_thin );
Styletb1.settopbordercolor (indexedcolors. Black. getindex ());
// | =
Cellstyle styletb2 = WB. createcellstyle ();
Styletb2.setborderbottom (cellstyle. border_thin );
Styletb2.setbottombordercolor (indexedcolors. Black. getindex ());
Styletb2.setborderleft (cellstyle. border_thin );
Styletb2.setleftbordercolor (indexedcolors. Black. getindex ());
Styletb2.setbordertop (cellstyle. border_thin );
Styletb1.settopbordercolor (indexedcolors. Black. getindex ());
// = |
Cellstyle style137= WB. createcellstyle ();
Styletb3.setborderright (cellstyle. border_thin );
Styletb3.setrightbordercolor (indexedcolors. Black. getindex ());
Styletb3.setborderbottom (cellstyle. border_thin );
Styletb3.setbottombordercolor (indexedcolors. Black. getindex ());
Styletb3.setbordertop (cellstyle. border_thin );
Styletb1.settopbordercolor (indexedcolors. Black. getindex ());
// | = |
Cellstyle styletb4 = WB. createcellstyle ();
Styletb4.setborderright (cellstyle. border_thin );
Styletb4.setrightbordercolor (indexedcolors. Black. getindex ());
Styletb4.setborderbottom (cellstyle. border_thin );
Styletb4.setbottombordercolor (indexedcolors. Black. getindex ());
Styletb4.setborderleft (cellstyle. border_thin );
Styletb4.setleftbordercolor (indexedcolors. Black. getindex ());
Styletb4.setbordertop (cellstyle. border_thin );
Styletb1.settopbordercolor (indexedcolors. Black. getindex ());

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.