用POI3.0导出EXCEL

Posted on 2007-09-26 17:47 angel 阅读(546) 评论(0)  编辑  收藏
 res.setContentType("application/vnd.ms-excel");
 OutputStream fos = res.getOutputStream();
HSSFWorkbook wb = new HSSFWorkbook();
 HSSFSheet s = wb.createSheet();
wb.setSheetName(0, "Matrix"); 
for(int i=0;i<15;i++){
HSSFRow row = s.createRow(i);
row.setHeight((short) 600);

 for(short j=0; j<title.length; j++) {
                HSSFCell cell = row.createCell(j);
                  s.setColumnWidth((short)j, (short)2500);
HSSFRichTextString ss = new
HSSFRichTextString("中文");
                    cell.setCellValue(ss);
}

}

 try {
            fos.flush();
            wb.write(fos);

        } catch (IOException e) {
            e.printStackTrace();
        }


 

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


网站导航:
 

Copyright © angel