1 Packagecn.shiyanjun.test;2 3 Importjava.util.ArrayList;4 Importjava.util.List;5 6 Public classExcelTest3 {7List<integer> RowData = GetRowData (17);8 Public Static voidMain (string[] args) {9ExcelTest3 ExcelTest3 =NewExcelTest3 ();Ten exceltest3.exportexceltest (); One } A - // ================================================================================================== - Public voidexportexceltest () { the intDatacount = Rowdata.size ();//Total Data - intExnum = 6;//number of exports per file - intQrynum = 8;//number of known queries - intQrycount =GetCount (datacount,qrynum); + intEnd = 1; - intFileNum = 0; +list<integer> list =NewArraylist<integer>(); A at for(inti = 0; i < Qrycount; i++) { -List<integer> beanlist =NewArraylist<integer>(); - if(I! = (qryCount-1)) {//if not the last query -Beanlist = Queryforpage (I*qrynum, (i+1) *qrynum);//Check 8 Records at a time. -}Else{ -Beanlist = Rowdata.sublist (i*Qrynum, datacount); in } - for(intj = 0; J < Beanlist.size (); J + +) {//Traverse these 8 data to List.add (Beanlist.get (j)); + if(list.size () = = Exnum | | (End ==qrycount && j = beanlist.size ()-1 )){ -System.out.println ((filenum+1) + ". xls");//Create a file theSYSTEM.OUT.PRINTLN ("Export" +list.size () + "bar data:" +list); * list.clear (); $filenum++;Panax Notoginseng } - } theend++; + } A the + } - $ PublicList<integer> Queryforpage (intStartIndex,intpageSize) { $List<integer> Pagedata =rowdata.sublist (StartIndex, pageSize); - returnPagedata; - } the - Wuyi //counting by Count and rows the Public intGetCount (intCountintrows) { - intnum = 1; Wu if(Count >=rows) { - if(count% rows = = 0){ Aboutnum = count/rows; $}Else{ -num = count/rows + 1; - } - } A returnnum; + } the - $ //Create a list collection that contains several 2-bit random integers the PublicList<integer> GetRowData (intcount) { thelist<integer> list =NewArraylist<integer>(); the for(inti = 0; I < count; i++){ the //int num = (int) math.round (math.random () *90+10); - List.add (i); in } the returnlist; the } About the Public voidPrintexcelapi (list<integer> exlist, list<integer>list) { the Exlist.addall (list); the } + -}
Test paging query out data and file export [Java Engineering]