随笔-200  评论-148  文章-15  trackbacks-0
网上搜集参考
public HSSFWorkbook getUserCardLogByCondition(List list,Integer total){
  HSSFWorkbook wb = new HSSFWorkbook();
  try{
      HSSFSheet sheet = wb.createSheet("吉林卡号数据统计");
      sheet.setColumnWidth((short)0, (short)4000);
      sheet.setColumnWidth((short)1, (short)4000);
            sheet.setColumnWidth((short)2, (short)4000);
            sheet.setColumnWidth((short)3, (short)4000);
            sheet.setColumnWidth((short)4, (short)4000);
            sheet.setColumnWidth((short)5, (short)4000);
            sheet.setColumnWidth((short)6, (short)5000);
            sheet.setColumnWidth((short)7, (short)5000);
            sheet.setColumnWidth((short)8, (short)5000);
          
            //格式设置
            HSSFCellStyle css = wb.createCellStyle();      
            css.setBorderBottom((short)1);          
            css.setBorderLeft((short)1);
            css.setBorderRight((short)1);
            css.setBorderTop((short)1);

            HSSFFont font = wb.createFont();  
            font.setFontHeightInPoints( (short) 24);  
            font.setFontName("宋体");  
          
            HSSFCellStyle style = wb.createCellStyle();
            style.setFont(font);
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER);

      HSSFRow row = sheet.createRow((short) 0);
      row.setHeight((short)600);
    
      HSSFCell cell = row.createCell((short) 0);
      cell.setCellStyle(style);
      cell.setCellValue(new HSSFRichTextString("吉林卡号数据统计"));
   
      sheet.addMergedRegion(new Region(0,(short)0,0,(short)8));
    
    
      row = sheet.createRow((short) 1);
      cell = row.createCell((short) 0);
    
      sheet.addMergedRegion(new Region(1,(short)0,1,(short)8));
    
  
    
      HSSFFont endfont = wb.createFont();  
      endfont.setFontHeightInPoints( (short) 12);  
      endfont.setFontName("宋体");
     
      HSSFCellStyle headstyle = wb.createCellStyle();
      headstyle.setFont(endfont);
      row = sheet.createRow((short) 2);
    
      String[] headTitle={"序列号","卡帐号","密码","卡类型","点数","卡状态","创建时间","激活时间","登陆时间"};
      for(int i=0;i<headTitle.length;i++){
       cell = row.createCell((short)i);
       cell.setCellStyle(headstyle);
       cell.setCellValue(new HSSFRichTextString(headTitle[i]));
      }
      for(int i=0;i<list.size();i++){
       UserCard userCard = (UserCard)list.get(i);
       row = sheet.createRow((short)(i+3));
       cell = row.createCell((short) 0);
       cell.setCellValue(new HSSFRichTextString(userCard.getId().toString()));
       cell = row.createCell((short) 1);
       cell.setCellValue(userCard.getUserName().toString());
       cell = row.createCell((short) 2);
       cell.setCellValue(userCard.getPassword().toString());
       cell = row.createCell((short) 3);
       cell.setCellValue(userCard.getTypeDes());
       cell = row.createCell((short) 4);
       cell.setCellValue(userCard.getValue().toString());
       cell = row.createCell((short) 5);
       cell.setCellValue(userCard.getStatusDes());
       cell = row.createCell((short) 6);
       cell.setCellValue(DateUtil.Format(userCard.getCreateTime(),"yyyy-HH-dd HH:mm:ss"));
       cell = row.createCell((short) 7);
       cell.setCellValue(DateUtil.Format(userCard.getActiveTime(),"yyyy-HH-dd HH:mm:ss"));
       cell = row.createCell((short) 8);
       cell.setCellValue(DateUtil.Format(userCard.getLoginTime(),"yyyy-HH-dd HH:mm:ss"));
      }
    
      row = sheet.createRow((short) (list.size()+6));
      cell = row.createCell((short) 0);
     
         
          
      HSSFCellStyle endstyle = wb.createCellStyle();
      endstyle.setFont(endfont);
      endstyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
           
      cell = row.createCell((short) 6);
      cell.setCellValue(new HSSFRichTextString("卡号合计:"));
      cell.setCellStyle(endstyle);
      cell = row.createCell((short) 7);
      cell.setCellValue(total.toString());
      row = sheet.createRow((short) (list.size()+7));
      cell = row.createCell((short) 6);
     
      }catch(Exception ex){
       ex.printStackTrace();
     }
     return wb;
 }

posted on 2010-06-01 10:31 无声 阅读(1301) 评论(0)  编辑  收藏 所属分类: 职场生活

只有注册用户登录后才能发表评论。


网站导航: