首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

导出execl公共种

2012-10-08 
导出execl公共类、protected HttpServletResponse getResponse() {return ServletActionContext.getRespons

导出execl公共类
、protected HttpServletResponse getResponse() {
return ServletActionContext.getResponse();
}

/** 
  * 输出表头 
  * @return 
  */

public void CraeateExce(String []select,String[] stitle,WritableSheet sheet){
try {     
               
         Label label2;     
         for(int i=0;i<select.length;i++){
      label2 = new Label(i,0,select[i],getSelectCellFormat());
      sheet.addCell(label2);  
        }
         for(int i=0;i<stitle.length;i++){     
               // Label(x,y,z)其中x代表单元格的第x+1列,第y+1行, 单元格的内容是y     
               // 在Label对象的子对象中指明单元格的位置和内容     
         byte[] countLength = stitle[i].getBytes();  
         sheet.setColumnView(i, countLength.length + 5);//设置行的宽度  
        // sheet.setRowView(i, 300);//设置行的高度  
               label2 = new Label(i,1,stitle[i],getTitleCellFormat());     
               // 将定义好的单元格添加到工作表中     
               sheet.addCell(label2);     
           }       
     } catch (Exception e) {     
         System.out.println("---出现异常---");     
         e.printStackTrace();     
     }     

}

热点排行