在Excel的一个sheet中导出大于20万的数据

第一:引用poi包。

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

第二:导出程序修改。

  FileInputStream file =null;
  OutputStream out = null;
  Workbook wb = null;
  Sheet sheet = null;

  wb = new SXSSFWorkbook(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 kennsakuSetubiDaitixyouKannri = itiranservice.kennsakuSetubiDaitixyouKannriA(selectSetbiItirannModel);
        double db = Double.parseDouble((java.util.Calendar.getInstance().getTimeInMillis() - stimee)+ "") * 0.001;
        System.out.println("第"+ie+"回----------"+ Double.parseDouble((java.util.Calendar.getInstance().getTimeInMillis() - stimee)+ "") * 0.001 +"秒");ie++;

         if (kennsakuSetubiDaitixyouKannri.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);

第三:样式代码

    //=
    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 styletb3 = 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());

你可能感兴趣的:(在Excel的一个sheet中导出大于20万的数据)