"> <" />
欢迎来到天天文库
浏览记录
ID:37710644
大小:54.00 KB
页数:9页
时间:2019-05-29
《jsp导出Excel 样式配置》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、jsp导出excel之格式控制2009-08-2614:43:29
2、分类:Java扩展
3、标签:
4、字号大中小订阅<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><%@pageimport="org.apache.poi.hssf.usermodel.*"%><%@pageimport="org.apache.poi.hssf.util.Region"%><%//获取参数StringsearcWord=request.getParameter("searchword");if(null==searcWor
5、d
6、
7、"".equals(searcWord.trim())){return;}else{searcWord=newString(searcWord.getBytes("iso-8859-1"),"UTF-8");Connectioncon=SQLServices.getConnection();ResultSetrs=con.executeSelect("qsssd",searcWord,false);if(null==rs){return;}else{//开始构造excel;try{//创建新的Excel工作簿HSSFWorkbookworkbook=newHSSFWorkb
8、ook();//在Excel工作簿中建一工作表,其名为缺省值。//也可以指定工作表的名字。HSSFSheetsheet=workbook.createSheet("Report");//==========================设置字体样式start==========================HSSFCellStylecs=workbook.createCellStyle();HSSFFontfont=workbook.createFont();font.setFontName("宋体");//设置字体font.setFontHeightInPoints((sh
9、ort)18);//字体大小font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//加粗cs.setFont(font);cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);//下边框cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框cs.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框cs.setBorderT
10、op(HSSFCellStyle.BORDER_THIN);//上边框HSSFCellStylecs2=workbook.createCellStyle();HSSFFontfont2=workbook.createFont();font2.setFontName("宋体");//设置字体font2.setFontHeightInPoints((short)12);//字体大小font2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//加粗cs2.setFont(font2);cs2.setAlignment(HSSFCellStyle.ALI
11、GN_CENTER);//水平居中cs2.setBorderBottom(HSSFCellStyle.BORDER_THIN);//下边框cs2.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框cs2.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框cs2.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框HSSFCellStylecs3=workbook.createCellStyle();HSSFFontfont3=workbook.createF
12、ont();font3.setFontName("宋体");font3.setFontHeightInPoints((short)10);cs3.setFont(font3);cs3.setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中cs3.setBorderBottom(HSSFCellStyle.BORDER_THIN);//下边框cs3.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框c
此文档下载收益归作者所有