首页 > 其他 > 详细

jxl实现的导出excel的功能

时间:2014-07-16 13:11:21      阅读:383      评论:0      收藏:0      [点我收藏+]

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>

<%@ page import="jxl.Workbook"%>

<%@ page import="jxl.format.Alignment"%>

<%@ page import="jxl.format.Border"%>

<%@ page import="jxl.format.BorderLineStyle"%>

<%@ page import="jxl.format.Colour"%>

<%@ page import="jxl.format.UnderlineStyle"%>


<%@ page import="jxl.write.Label"%>

<%@ page import="jxl.write.WritableCellFormat"%>

<%@ page import="jxl.write.WritableFont"%>

<%@ page import="jxl.write.WritableSheet"%>

<%@ page import="jxl.write.WritableWorkbook"%>

<%@ page import="jxl.write.WriteException"%>

<%

response.reset();

response.addHeader("Content-Disposition", "attachment;filename="+new String("1.xls".getBytes("GB2312"),"ISO8859-1"));

WritableWorkbook wwb = Workbook.createWorkbook(response.getOutputStream());

WritableSheet ws = wwb.createSheet("报表", 0);

int[] colsWidth = new int[2];

WritableFont wfc = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLUE);

WritableCellFormat wcfFC = new WritableCellFormat(wfc);

wcfFC.setAlignment(Alignment.CENTRE);

wcfFC.setBorder(Border.ALL, BorderLineStyle.THIN);

Label heaLabel = new Label(0,0,"id",wcfFC);

ws.addCell(heaLabel);

heaLabel = new Label(1,0,"name",wcfFC);

ws.addCell(heaLabel);

heaLabel = new Label(0,1,"1",wcfFC);

ws.addCell(heaLabel);

heaLabel = new Label(1,1,"1",wcfFC);

ws.addCell(heaLabel);

wwb.write();

wwb.close();

out.clear();

out = pageContext.pushBody();

%>

简单的实现留作以后如果忘记了还可以再看看

jxl实现的导出excel的功能,布布扣,bubuko.com

jxl实现的导出excel的功能

原文:http://4449493.blog.51cto.com/4439493/1438893

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!