java jxl 导出数据 合并单元格

String[] listtit={"个数","原价(元)","代理(元)","通道(元)","个数","原价(元)","代理(元)","通道(元)","个数","原价(元)","代理(元)","通道(元)","个数","原价(元)","代理(元)","通道(元)"};
        File exfile=new File("G:/statuReport.xls");
         WritableFont font1 = new WritableFont(WritableFont.ARIAL,12,WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
        WritableCellFormat format1=new WritableCellFormat(font1);
        format1.setAlignment(Alignment.CENTRE);
        //format1.setBackground(Colour.GRAY_25);
        format1.setVerticalAlignment(VerticalAlignment.TOP);
        
        
        WritableCellFormat format=new WritableCellFormat();
        format.setAlignment(Alignment.CENTRE);
        
        format.setVerticalAlignment(VerticalAlignment.TOP);
        WritableWorkbook workbook=Workbook.createWorkbook(exfile);
        WritableSheet sheet1=workbook.createSheet("代理", 0);
             sheet1.addCell(new Label(0, 0, "代理ID", format1));
           sheet1.addCell(new Label(1, 0, "代理账号", format1));
           sheet1.addCell(new Label(2, 0, "提交成功", format1));
           sheet1.addCell(new Label(6, 0, "提交失败", format1));
           sheet1.addCell(new Label(10, 0, "充值失败", format1));
           sheet1.addCell(new Label(14, 0, "充值成功", format1));
           sheet1.addCell(new Label(18, 0, "毛利", format1));
           sheet1.mergeCells( 0, 0, 0, 1);
           sheet1.mergeCells( 1, 0, 1, 1);
           sheet1.mergeCells( 2, 0, 5, 0);
           sheet1.mergeCells( 6, 0, 9, 0);
           sheet1.mergeCells( 10, 0, 13, 0);
           sheet1.mergeCells( 14, 0, 17, 0);
           sheet1.mergeCells( 18, 0, 18, 1);
           for(int i=0; i                sheet1.addCell(new Label(i+2, 1, listtit[i], format1));
               
           }
           StatusReportDao srd=new StatusReportImp();
            List clist=    srd.selectStatusReportFromSubmitreattimeAgent(starttime+" 00:00:00", endtime+" 24:00:00",agent);
           SettlementAction sa=new SettlementAction();
         List lists= new ArrayList();
         List list1= new ArrayList();
         for(int i=0;i<19;i++){
             list1.add("你好"+i);
            
         }
           lists.add(list1);
           lists.add(list1);
           lists.add(list1);
         //int row=1;
         for(int i=0;i              List listm=(List) lists.get(i);
             int clos=0;
             for (int j = 0; j < listm.size(); j++) {
                 sheet1.addCell(new Label(clos+j, i+2, listm.get(j)+"",format));
            }
            
         }
           workbook.write();
           workbook.close();

你可能感兴趣的:(java,jsp)